org.bitcoinj.core.InsufficientMoneyException Java Examples

The following examples show how to use org.bitcoinj.core.InsufficientMoneyException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WalletService.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
public void emptyWallet(String toAddress, KeyParameter aesKey, ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler)
        throws InsufficientMoneyException, AddressFormatException {
    SendRequest sendRequest = SendRequest.emptyWallet(Address.fromBase58(params, toAddress));
    sendRequest.fee = Coin.ZERO;
    sendRequest.feePerKb = getTxFeeForWithdrawalPerByte().multiply(1000);
    sendRequest.aesKey = aesKey;
    Wallet.SendResult sendResult = wallet.sendCoins(sendRequest);
    printTx("empty wallet", sendResult.tx);
    Futures.addCallback(sendResult.broadcastComplete, new FutureCallback<Transaction>() {
        @Override
        public void onSuccess(Transaction result) {
            log.info("emptyWallet onSuccess Transaction=" + result);
            resultHandler.handleResult();
        }

        @Override
        public void onFailure(@NotNull Throwable t) {
            log.error("emptyWallet onFailure " + t.toString());
            errorMessageHandler.handleErrorMessage(t.getMessage());
        }
    });
}
 
Example #2
Source File: TxFeeEstimationServiceTest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
@Ignore
public void testGetEstimatedTxSize_withLargeTx() throws InsufficientMoneyException {
    List<Coin> outputValues = List.of(Coin.valueOf(2000), Coin.valueOf(3000));
    int initialEstimatedTxSize;
    Coin txFeePerByte;
    BtcWalletService btcWalletService = mock(BtcWalletService.class);
    int result;
    int realTxSize;
    Coin txFee;

    initialEstimatedTxSize = 260;
    txFeePerByte = Coin.valueOf(10);
    realTxSize = 2600;

    txFee = txFeePerByte.multiply(initialEstimatedTxSize);
    when(btcWalletService.getEstimatedFeeTxSize(outputValues, txFee)).thenReturn(realTxSize);

    // repeated calls to getEstimatedFeeTxSize do not work (returns 0 at second call in loop which cause test to fail)
    result = TxFeeEstimationService.getEstimatedTxSize(outputValues, initialEstimatedTxSize, txFeePerByte, btcWalletService);
    assertEquals(2600, result);
}
 
Example #3
Source File: WalletTest.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void lowerThanDefaultFee() throws InsufficientMoneyException {
    int feeFactor = 50;
    Coin fee = Transaction.DEFAULT_TX_FEE.divide(feeFactor);
    receiveATransactionAmount(wallet, myAddress, Coin.COIN);
    SendRequest req = SendRequest.to(myAddress, Coin.CENT);
    req.feePerKb = fee;
    wallet.completeTx(req);
    assertEquals(Coin.valueOf(22700).divide(feeFactor), req.tx.getFee());
    wallet.commitTx(req.tx);
    SendRequest emptyReq = SendRequest.emptyWallet(myAddress);
    emptyReq.feePerKb = fee;
    emptyReq.ensureMinRequiredFee = true;
    emptyReq.emptyWallet = true;
    emptyReq.coinSelector = AllowUnconfirmedCoinSelector.get();
    wallet.completeTx(emptyReq);
    assertEquals(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE, emptyReq.tx.getFee());
    wallet.commitTx(emptyReq.tx);
}
 
Example #4
Source File: WalletService.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public void emptyWallet(String toAddress,
                        KeyParameter aesKey,
                        ResultHandler resultHandler,
                        ErrorMessageHandler errorMessageHandler)
        throws InsufficientMoneyException, AddressFormatException {
    SendRequest sendRequest = SendRequest.emptyWallet(Address.fromBase58(params, toAddress));
    sendRequest.fee = Coin.ZERO;
    sendRequest.feePerKb = getTxFeeForWithdrawalPerByte().multiply(1000);
    sendRequest.aesKey = aesKey;
    Wallet.SendResult sendResult = wallet.sendCoins(sendRequest);
    printTx("empty wallet", sendResult.tx);
    Futures.addCallback(sendResult.broadcastComplete, new FutureCallback<Transaction>() {
        @Override
        public void onSuccess(Transaction result) {
            log.info("emptyWallet onSuccess Transaction=" + result);
            resultHandler.handleResult();
        }

        @Override
        public void onFailure(@NotNull Throwable t) {
            log.error("emptyWallet onFailure " + t.toString());
            errorMessageHandler.handleErrorMessage(t.getMessage());
        }
    });
}
 
Example #5
Source File: TxFeeEstimationService.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public Tuple2<Coin, Integer> getEstimatedFeeAndTxSize(Coin amount,
                                                      FeeService feeService,
                                                      BtcWalletService btcWalletService) {
    Coin txFeePerByte = feeService.getTxFeePerByte();
    // We start with min taker fee size of 260
    int estimatedTxSize = TYPICAL_TX_WITH_1_INPUT_SIZE;
    try {
        estimatedTxSize = getEstimatedTxSize(List.of(amount), estimatedTxSize, txFeePerByte, btcWalletService);
    } catch (InsufficientMoneyException e) {
        log.info("We cannot do the fee estimation because there are not enough funds in the wallet. This is expected " +
                "if the user pays from an external wallet. In that case we use an estimated tx size of {} bytes.", estimatedTxSize);
    }

    Coin txFee = txFeePerByte.multiply(estimatedTxSize);
    log.info("Fee estimation resulted in a tx size of {} bytes and a tx fee of {} Sat.", estimatedTxSize, txFee.value);

    return new Tuple2<>(txFee, estimatedTxSize);
}
 
Example #6
Source File: BaseProposalFactory.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private Transaction createTransaction(R proposal) throws InsufficientMoneyException, TxException {
    try {
        Coin fee = ProposalConsensus.getFee(daoStateService, daoStateService.getChainHeight());
        // We create a prepared Bsq Tx for the proposal fee.
        Transaction preparedBurnFeeTx = proposal instanceof IssuanceProposal ?
                bsqWalletService.getPreparedIssuanceTx(fee) :
                bsqWalletService.getPreparedProposalTx(fee);

        // payload does not have txId at that moment
        byte[] hashOfPayload = ProposalConsensus.getHashOfPayload(proposal);
        byte[] opReturnData = getOpReturnData(hashOfPayload);

        // We add the BTC inputs for the miner fee.
        Transaction txWithBtcFee = completeTx(preparedBurnFeeTx, opReturnData, proposal);

        // We sign the BSQ inputs of the final tx.
        Transaction transaction = bsqWalletService.signTx(txWithBtcFee);
        log.info("Proposal tx: " + transaction);
        return transaction;
    } catch (WalletException | TransactionVerificationException e) {
        throw new TxException(e);
    }
}
 
Example #7
Source File: ProposalsView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void onVote() {
    Coin stake = ParsingUtils.parseToCoin(stakeInputTextField.getText(), bsqFormatter);
    try {
        // We create a dummy tx to get the miningFee for displaying it at the confirmation popup
        Tuple2<Coin, Integer> miningFeeAndTxSize = daoFacade.getBlindVoteMiningFeeAndTxSize(stake);
        Coin miningFee = miningFeeAndTxSize.first;
        int txSize = miningFeeAndTxSize.second;
        Coin blindVoteFee = daoFacade.getBlindVoteFeeForCycle();
        if (!DevEnv.isDevMode()) {
            GUIUtil.showBsqFeeInfoPopup(blindVoteFee, miningFee, txSize, bsqFormatter, btcFormatter,
                    Res.get("dao.blindVote"), () -> publishBlindVote(stake));
        } else {
            publishBlindVote(stake);
        }
    } catch (InsufficientMoneyException | WalletException | TransactionVerificationException exception) {
        new Popup().warning(exception.toString()).show();
    }
}
 
Example #8
Source File: WalletTest.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void higherThanDefaultFee() throws InsufficientMoneyException {
    int feeFactor = 10;
    Coin fee = Transaction.DEFAULT_TX_FEE.multiply(feeFactor);
    receiveATransactionAmount(wallet, myAddress, Coin.COIN);
    SendRequest req = SendRequest.to(myAddress, Coin.CENT);
    req.feePerKb = fee;
    wallet.completeTx(req);
    assertEquals(Coin.valueOf(11350).multiply(feeFactor), req.tx.getFee());
    wallet.commitTx(req.tx);
    SendRequest emptyReq = SendRequest.emptyWallet(myAddress);
    emptyReq.feePerKb = fee;
    emptyReq.emptyWallet = true;
    emptyReq.coinSelector = AllowUnconfirmedCoinSelector.get();
    wallet.completeTx(emptyReq);
    assertEquals(Coin.valueOf(171000), emptyReq.tx.getFee());
    wallet.commitTx(emptyReq.tx);
}
 
Example #9
Source File: BaseProposalService.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
protected Transaction createTransaction(R proposal) throws InsufficientMoneyException, TxException {
    try {
        final Coin fee = proposalConsensus.getFee(bsqStateService, bsqStateService.getChainHeight());
        // We create a prepared Bsq Tx for the proposal fee.
        final Transaction preparedBurnFeeTx = bsqWalletService.getPreparedProposalTx(fee);

        // payload does not have txId at that moment
        byte[] hashOfPayload = proposalConsensus.getHashOfPayload(proposal);
        byte[] opReturnData = getOpReturnData(hashOfPayload);

        // We add the BTC inputs for the miner fee.
        final Transaction txWithBtcFee = completeTx(preparedBurnFeeTx, opReturnData, proposal);

        // We sign the BSQ inputs of the final tx.
        Transaction transaction = bsqWalletService.signTx(txWithBtcFee);
        log.info("Proposal tx: " + transaction);
        return transaction;
    } catch (WalletException | TransactionVerificationException e) {
        throw new TxException(e);
    }
}
 
Example #10
Source File: ProofOfBurnService.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public Transaction burn(String preImageAsString, long amount) throws InsufficientMoneyException, TxException {
    try {
        // We create a prepared Bsq Tx for the burn amount
        Transaction preparedBurnFeeTx = bsqWalletService.getPreparedProofOfBurnTx(Coin.valueOf(amount));
        byte[] hash = getHashFromPreImage(preImageAsString);
        byte[] opReturnData = ProofOfBurnConsensus.getOpReturnData(hash);
        // We add the BTC inputs for the miner fee.
        Transaction txWithBtcFee = btcWalletService.completePreparedBurnBsqTx(preparedBurnFeeTx, opReturnData);
        // We sign the BSQ inputs of the final tx.
        Transaction transaction = bsqWalletService.signTx(txWithBtcFee);
        log.info("Proof of burn tx: " + transaction);
        return transaction;
    } catch (WalletException | TransactionVerificationException e) {
        throw new TxException(e);
    }
}
 
Example #11
Source File: WalletTest.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void lowerThanDefaultFee() throws InsufficientMoneyException {
    int feeFactor = 10;
    Coin fee = Transaction.DEFAULT_TX_FEE.divide(feeFactor);
    receiveATransactionAmount(wallet, myAddress, Coin.COIN);
    SendRequest req = SendRequest.to(myAddress, Coin.CENT);
    req.feePerKb = fee;
    wallet.completeTx(req);
    assertEquals(Coin.valueOf(11350).divide(feeFactor), req.tx.getFee());
    wallet.commitTx(req.tx);
    SendRequest emptyReq = SendRequest.emptyWallet(myAddress);
    emptyReq.feePerKb = fee;
    emptyReq.ensureMinRequiredFee = true;
    emptyReq.emptyWallet = true;
    emptyReq.coinSelector = AllowUnconfirmedCoinSelector.get();
    wallet.completeTx(emptyReq);
    assertEquals(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE, emptyReq.tx.getFee());
    wallet.commitTx(emptyReq.tx);
}
 
Example #12
Source File: BtcWalletService.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
public Transaction completePreparedSendBsqTx(Transaction preparedBsqTx, boolean isSendTx) throws
        TransactionVerificationException, WalletException, InsufficientMoneyException {
    // preparedBsqTx has following structure:
    // inputs [1-n] BSQ inputs
    // outputs [0-1] BSQ receivers output
    // outputs [0-1] BSQ change output

    // We add BTC mining fee. Result tx looks like:
    // inputs [1-n] BSQ inputs
    // inputs [1-n] BTC inputs
    // outputs [0-1] BSQ receivers output
    // outputs [0-1] BSQ change output
    // outputs [0-1] BTC change output
    // mining fee: BTC mining fee
    return completePreparedBsqTx(preparedBsqTx, isSendTx, null);
}
 
Example #13
Source File: WalletTest.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
@Test(expected = Wallet.DustySendRequested.class)
public void sendDustTest() throws InsufficientMoneyException {
    // Tests sending dust, should throw DustySendRequested.
    Transaction tx = new Transaction(PARAMS);
    tx.addOutput(Transaction.MIN_NONDUST_OUTPUT.subtract(SATOSHI), OTHER_ADDRESS);
    SendRequest request = SendRequest.forTx(tx);
    request.ensureMinRequiredFee = true;
    wallet.completeTx(request);
}
 
Example #14
Source File: WalletTest.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@Test(expected = InsufficientMoneyException.class)
public void watchingScriptsConfirmed() throws Exception {
    Address watchedAddress = new ECKey().toAddress(PARAMS);
    wallet.addWatchedAddress(watchedAddress);
    sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, CENT, watchedAddress);
    assertEquals(CENT, wallet.getBalance());

    // We can't spend watched balances
    wallet.createSend(OTHER_ADDRESS, CENT);
}
 
Example #15
Source File: WalletTest.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void importAndEncrypt() throws InsufficientMoneyException {
    Wallet encryptedWallet = new Wallet(PARAMS);
    encryptedWallet.encrypt(PASSWORD1);

    final ECKey key = new ECKey();
    encryptedWallet.importKeysAndEncrypt(ImmutableList.of(key), PASSWORD1);
    assertEquals(1, encryptedWallet.getImportedKeys().size());
    assertEquals(key.getPubKeyPoint(), encryptedWallet.getImportedKeys().get(0).getPubKeyPoint());
    sendMoneyToWallet(encryptedWallet, AbstractBlockChain.NewBlockType.BEST_CHAIN, Coin.COIN, key.toAddress(PARAMS));
    assertEquals(Coin.COIN, encryptedWallet.getBalance());
    SendRequest req = SendRequest.emptyWallet(OTHER_ADDRESS);
    req.aesKey = checkNotNull(encryptedWallet.getKeyCrypter()).deriveKey(PASSWORD1);
    encryptedWallet.sendCoinsOffline(req);
}
 
Example #16
Source File: UnlockTxService.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Transaction getUnlockTx(String lockupTxId)
        throws InsufficientMoneyException, WalletException, TransactionVerificationException {
    Optional<TxOutput> optionalLockupTxOutput = daoStateService.getLockupTxOutput(lockupTxId);
    checkArgument(optionalLockupTxOutput.isPresent(), "lockupTxOutput must be present");
    TxOutput lockupTxOutput = optionalLockupTxOutput.get();
    Transaction preparedTx = bsqWalletService.getPreparedUnlockTx(lockupTxOutput);
    Transaction txWithBtcFee = btcWalletService.completePreparedBsqTx(preparedTx, true, null);
    Transaction transaction = bsqWalletService.signTx(txWithBtcFee);
    log.info("Unlock tx: " + transaction);
    return transaction;
}
 
Example #17
Source File: ChangeParamProposalFactory.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public ProposalWithTransaction createProposalWithTransaction(String name,
                                                             String link,
                                                             Param param,
                                                             String paramValue)
        throws ProposalValidationException, InsufficientMoneyException, TxException {
    this.param = param;
    this.paramValue = paramValue;

    return super.createProposalWithTransaction(name, link);
}
 
Example #18
Source File: WalletTest.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void sendCoinsWithBroadcasterTest() throws InsufficientMoneyException {
    ECKey key = ECKey.fromPrivate(BigInteger.TEN);
    receiveATransactionAmount(wallet, myAddress, Coin.COIN);
    MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet);
    wallet.setTransactionBroadcaster(broadcaster);
    SendRequest req = SendRequest.to(OTHER_ADDRESS.getParameters(), key, Coin.CENT);
    wallet.sendCoins(req);
}
 
Example #19
Source File: DaoFacade.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public ProposalWithTransaction getParamProposalWithTransaction(String name,
                                                               String link,
                                                               Param param,
                                                               String paramValue)
        throws ProposalValidationException, InsufficientMoneyException, TxException {
    return changeParamProposalFactory.createProposalWithTransaction(name,
            link,
            param,
            paramValue);
}
 
Example #20
Source File: LockupTxService.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public Tuple2<Coin, Integer> getMiningFeeAndTxSize(Coin lockupAmount, int lockTime, LockupReason lockupReason, byte[] hash)
        throws InsufficientMoneyException, WalletException, TransactionVerificationException, IOException {
    Transaction tx = getLockupTx(lockupAmount, lockTime, lockupReason, hash);
    Coin miningFee = tx.getFee();
    int txSize = tx.bitcoinSerialize().length;
    return new Tuple2<>(miningFee, txSize);
}
 
Example #21
Source File: DaoFacade.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public ProposalWithTransaction getReimbursementProposalWithTransaction(String name,
                                                                       String link,
                                                                       Coin requestedBsq)
        throws ProposalValidationException, InsufficientMoneyException, TxException {
    return reimbursementProposalFactory.createProposalWithTransaction(name,
            link,
            requestedBsq);
}
 
Example #22
Source File: BtcWalletService.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public Transaction getFeeEstimationTransaction(String fromAddress,
                                               String toAddress,
                                               Coin amount,
                                               AddressEntry.Context context)
        throws AddressFormatException, AddressEntryException, InsufficientFundsException {

    Optional<AddressEntry> addressEntry = findAddressEntry(fromAddress, context);
    if (!addressEntry.isPresent())
        throw new AddressEntryException("WithdrawFromAddress is not found in our wallet.");

    checkNotNull(addressEntry.get().getAddress(), "addressEntry.get().getAddress() must nto be null");

    try {
        Coin fee;
        int counter = 0;
        int txSize = 0;
        Transaction tx;
        Coin txFeeForWithdrawalPerByte = getTxFeeForWithdrawalPerByte();
        do {
            counter++;
            fee = txFeeForWithdrawalPerByte.multiply(txSize);
            SendRequest sendRequest = getSendRequest(fromAddress, toAddress, amount, fee, aesKey, context);
            wallet.completeTx(sendRequest);
            tx = sendRequest.tx;
            txSize = tx.bitcoinSerialize().length;
            printTx("FeeEstimationTransaction", tx);
        }
        while (feeEstimationNotSatisfied(counter, tx));
        if (counter == 10)
            log.error("Could not calculate the fee. Tx=" + tx);

        return tx;
    } catch (InsufficientMoneyException e) {
        throw new InsufficientFundsException("The fees for that transaction exceed the available funds " +
                "or the resulting output value is below the min. dust value:\n" +
                "Missing " + (e.missing != null ? e.missing.toFriendlyString() : "null"));
    }
}
 
Example #23
Source File: BtcWalletService.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
public String sendFunds(String fromAddress,
                        String toAddress,
                        Coin receiverAmount,
                        Coin fee,
                        @Nullable KeyParameter aesKey,
                        @SuppressWarnings("SameParameterValue") AddressEntry.Context context,
                        FutureCallback<Transaction> callback) throws AddressFormatException,
        AddressEntryException, InsufficientMoneyException {
    SendRequest sendRequest = getSendRequest(fromAddress, toAddress, receiverAmount, fee, aesKey, context);
    Wallet.SendResult sendResult = wallet.sendCoins(sendRequest);
    Futures.addCallback(sendResult.broadcastComplete, callback);

    printTx("sendFunds", sendResult.tx);
    return sendResult.tx.getHashAsString();
}
 
Example #24
Source File: WalletTest.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void sendCoinsWithBroadcasterTest() throws InsufficientMoneyException {
    ECKey key = ECKey.fromPrivate(BigInteger.TEN);
    receiveATransactionAmount(wallet, myAddress, Coin.COIN);
    MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet);
    wallet.setTransactionBroadcaster(broadcaster);
    SendRequest req = SendRequest.to(OTHER_ADDRESS.getParameters(), key, Coin.CENT);
    wallet.sendCoins(req);
}
 
Example #25
Source File: BtcWalletService.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
private Transaction completePreparedBsqTxWithBtcFee(Transaction preparedTx, byte[] opReturnData) throws InsufficientMoneyException, TransactionVerificationException, WalletException {
    // Remember index for first BTC input
    int indexOfBtcFirstInput = preparedTx.getInputs().size();

    Transaction tx = addInputsForMinerFee(preparedTx, opReturnData);
    signAllBtcInputs(indexOfBtcFirstInput, tx);

    checkWalletConsistency(wallet);
    verifyTransaction(tx);

    // printTx("BTC wallet: Signed tx", tx);
    return tx;
}
 
Example #26
Source File: BtcWalletService.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
public Transaction completePreparedProposalTx(Transaction preparedBurnFeeTx, byte[] opReturnData) {
    try {
        //TODO dummy
        return completePreparedCompensationRequestTx(Coin.valueOf(10000), getFreshAddressEntry().getAddress(),
                preparedBurnFeeTx, opReturnData);
    } catch (TransactionVerificationException | InsufficientMoneyException | WalletException e) {
        e.printStackTrace();
    }
    throw new RuntimeException("completePreparedGenericProposalTx not implemented yet.");
}
 
Example #27
Source File: BsqWalletService.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
public Transaction getPreparedSendBtcTx(String receiverAddress, Coin receiverAmount)
        throws AddressFormatException, InsufficientBsqException, WalletException, TransactionVerificationException {
    Transaction tx = new Transaction(params);
    checkArgument(Restrictions.isAboveDust(receiverAmount),
            "The amount is too low (dust limit).");
    tx.addOutput(receiverAmount, Address.fromBase58(params, receiverAddress));

    SendRequest sendRequest = SendRequest.forTx(tx);
    sendRequest.fee = Coin.ZERO;
    sendRequest.feePerKb = Coin.ZERO;
    sendRequest.ensureMinRequiredFee = false;
    sendRequest.aesKey = aesKey;
    sendRequest.shuffleOutputs = false;
    sendRequest.signInputs = false;
    sendRequest.ensureMinRequiredFee = false;
    sendRequest.changeAddress = getUnusedAddress();
    sendRequest.coinSelector = nonBsqCoinSelector;
    try {
        wallet.completeTx(sendRequest);
    } catch (InsufficientMoneyException e) {
        throw new InsufficientBsqException(e.missing);
    }
    checkWalletConsistency(wallet);
    verifyTransaction(tx);
    // printTx("prepareSendTx", tx);
    return tx;
}
 
Example #28
Source File: CompensationProposalFactory.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected Transaction completeTx(Transaction preparedBurnFeeTx, byte[] opReturnData, Proposal proposal)
        throws WalletException, InsufficientMoneyException, TransactionVerificationException {
    CompensationProposal compensationProposal = (CompensationProposal) proposal;
    return btcWalletService.completePreparedCompensationRequestTx(
            compensationProposal.getRequestedBsq(),
            compensationProposal.getAddress(),
            preparedBurnFeeTx,
            opReturnData);
}
 
Example #29
Source File: BtcEmptyWalletWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void doEmptyWallet2(KeyParameter aesKey) {
    emptyWalletButton.setDisable(true);
    openOfferManager.removeAllOpenOffers(() -> {
        try {
            btcWalletService.emptyWallet(addressInputTextField.getText(),
                    aesKey,
                    () -> {
                        closeButton.updateText(Res.get("shared.close"));
                        balanceTextField.setText(btcFormatter.formatCoinWithCode(btcWalletService.getAvailableConfirmedBalance()));
                        emptyWalletButton.setDisable(true);
                        log.debug("wallet empty successful");
                        onClose(() -> UserThread.runAfter(() -> new Popup()
                                .feedback(Res.get("emptyWalletWindow.sent.success"))
                                .show(), Transitions.DEFAULT_DURATION, TimeUnit.MILLISECONDS));
                        doClose();
                    },
                    (errorMessage) -> {
                        emptyWalletButton.setDisable(false);
                        log.error("wallet empty failed {}", errorMessage);
                    });
        } catch (InsufficientMoneyException | AddressFormatException e1) {
            e1.printStackTrace();
            log.error(e1.getMessage());
            emptyWalletButton.setDisable(false);
        }
    });
}
 
Example #30
Source File: DaoFacade.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public ProposalWithTransaction getConfiscateBondProposalWithTransaction(String name,
                                                                        String link,
                                                                        String lockupTxId)
        throws ProposalValidationException, InsufficientMoneyException, TxException {
    return confiscateBondProposalFactory.createProposalWithTransaction(name,
            link,
            lockupTxId);
}