diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index a68cd42224..e65e1126df 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2262,7 +2262,7 @@ dao.wallet.send.setDestinationAddress=Fill in your destination address dao.wallet.send.send=Send BSQ funds dao.wallet.send.sendBtc=Send BTC funds dao.wallet.send.sendFunds.headline=Confirm withdrawal request -dao.wallet.send.sendFunds.details=Sending: {0}\nTo receiving address: {1}.\nRequired transaction fee is: {2} ({3} satoshis/byte)\nTransaction size: {4} Kb\n\nThe recipient will receive: {5}\n\nAre you sure you want to withdraw that amount? +dao.wallet.send.sendFunds.details=Sending: {0}\nTo receiving address: {1}.\nRequired mining fee is: {2} ({3} satoshis/byte)\nTransaction size: {4} Kb\n\nThe recipient will receive: {5}\n\nAre you sure you want to withdraw that amount? dao.wallet.chainHeightSynced=Latest verified block: {0} dao.wallet.chainHeightSyncing=Awaiting blocks... Verified {0} blocks out of {1} dao.wallet.tx.type=Type diff --git a/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java b/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java index 0c8a6cd841..fa638c4a19 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java @@ -27,6 +27,7 @@ import bisq.desktop.main.dao.wallet.BsqBalanceUtil; import bisq.desktop.main.funds.FundsView; import bisq.desktop.main.funds.deposit.DepositView; import bisq.desktop.main.overlays.popups.Popup; +import bisq.desktop.main.overlays.windows.WalletPasswordWindow; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; import bisq.desktop.util.validation.BsqAddressValidator; @@ -53,6 +54,7 @@ import bisq.core.util.validation.BtcAddressValidator; import bisq.network.p2p.P2PService; +import bisq.common.UserThread; import bisq.common.handlers.ResultHandler; import org.bitcoinj.core.Coin; @@ -67,6 +69,8 @@ import javafx.scene.layout.GridPane; import javafx.beans.value.ChangeListener; +import java.util.concurrent.TimeUnit; + import static bisq.desktop.util.FormBuilder.addButtonAfterGroup; import static bisq.desktop.util.FormBuilder.addInputTextField; import static bisq.desktop.util.FormBuilder.addTitledGroupBg; @@ -86,6 +90,7 @@ public class BsqSendView extends ActivatableView implements BsqB private final BtcValidator btcValidator; private final BsqAddressValidator bsqAddressValidator; private final BtcAddressValidator btcAddressValidator; + private final WalletPasswordWindow walletPasswordWindow; private int gridRow = 0; private InputTextField amountInputTextField, btcAmountInputTextField; @@ -113,7 +118,8 @@ public class BsqSendView extends ActivatableView implements BsqB BsqValidator bsqValidator, BtcValidator btcValidator, BsqAddressValidator bsqAddressValidator, - BtcAddressValidator btcAddressValidator) { + BtcAddressValidator btcAddressValidator, + WalletPasswordWindow walletPasswordWindow) { this.bsqWalletService = bsqWalletService; this.btcWalletService = btcWalletService; this.walletsManager = walletsManager; @@ -127,6 +133,7 @@ public class BsqSendView extends ActivatableView implements BsqB this.btcValidator = btcValidator; this.bsqAddressValidator = bsqAddressValidator; this.btcAddressValidator = btcAddressValidator; + this.walletPasswordWindow = walletPasswordWindow; } @Override @@ -362,7 +369,7 @@ public class BsqSendView extends ActivatableView implements BsqB amountFormatter.formatCoinWithCode(receiverAmount))) .actionButtonText(Res.get("shared.yes")) .onAction(() -> { - walletsManager.publishAndCommitBsqTx(txWithBtcFee, txType, new TxBroadcaster.Callback() { + doWithdraw(txWithBtcFee, txType, new TxBroadcaster.Callback() { @Override public void onSuccess(Transaction transaction) { log.debug("Successfully sent tx with id {}", txWithBtcFee.getTxId().toString()); @@ -378,5 +385,19 @@ public class BsqSendView extends ActivatableView implements BsqB .closeButtonText(Res.get("shared.cancel")) .show(); } + + private void doWithdraw(Transaction txWithBtcFee, TxType txType, TxBroadcaster.Callback callback) { + if (btcWalletService.isEncrypted()) { + UserThread.runAfter(() -> walletPasswordWindow.onAesKey(aesKey -> + sendFunds(txWithBtcFee, txType, callback)) + .show(), 300, TimeUnit.MILLISECONDS); + } else { + sendFunds(txWithBtcFee, txType, callback); + } + } + + private void sendFunds(Transaction txWithBtcFee, TxType txType, TxBroadcaster.Callback callback) { + walletsManager.publishAndCommitBsqTx(txWithBtcFee, txType, callback); + } }