From 864700775bbd4065baabce58c0ffa403bcd75482 Mon Sep 17 00:00:00 2001 From: Oscar Guindzberg Date: Mon, 12 Oct 2020 17:23:20 -0300 Subject: [PATCH] Accept segwit addresses when sending non-BSQ funds --- .../bisq/core/btc/wallet/BsqWalletService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java b/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java index 7fd1229cfaa..d85b8ac40ed 100644 --- a/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java +++ b/core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java @@ -513,7 +513,7 @@ public void commitTx(Transaction tx, TxType txType) { public Transaction getPreparedSendBsqTx(String receiverAddress, Coin receiverAmount) throws AddressFormatException, InsufficientBsqException, WalletException, TransactionVerificationException, BsqChangeBelowDustException { - return getPreparedSendTx(receiverAddress, receiverAmount, bsqCoinSelector); + return getPreparedSendTx(receiverAddress, receiverAmount, bsqCoinSelector, false); } /////////////////////////////////////////////////////////////////////////////////////////// @@ -522,17 +522,21 @@ public Transaction getPreparedSendBsqTx(String receiverAddress, Coin receiverAmo public Transaction getPreparedSendBtcTx(String receiverAddress, Coin receiverAmount) throws AddressFormatException, InsufficientBsqException, WalletException, TransactionVerificationException, BsqChangeBelowDustException { - return getPreparedSendTx(receiverAddress, receiverAmount, nonBsqCoinSelector); + return getPreparedSendTx(receiverAddress, receiverAmount, nonBsqCoinSelector, true); } - private Transaction getPreparedSendTx(String receiverAddress, Coin receiverAmount, CoinSelector coinSelector) + private Transaction getPreparedSendTx(String receiverAddress, Coin receiverAmount, CoinSelector coinSelector, + boolean allowSegwitOuput) throws AddressFormatException, InsufficientBsqException, WalletException, TransactionVerificationException, BsqChangeBelowDustException { daoKillSwitch.assertDaoIsNotDisabled(); Transaction tx = new Transaction(params); checkArgument(Restrictions.isAboveDust(receiverAmount), "The amount is too low (dust limit)."); - tx.addOutput(receiverAmount, LegacyAddress.fromBase58(params, receiverAddress)); - + if (allowSegwitOuput) { + tx.addOutput(receiverAmount, Address.fromString(params, receiverAddress)); + } else { + tx.addOutput(receiverAmount, LegacyAddress.fromBase58(params, receiverAddress)); + } SendRequest sendRequest = SendRequest.forTx(tx); sendRequest.fee = Coin.ZERO; sendRequest.feePerKb = Coin.ZERO;