mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-11-17 08:17:57 +00:00
prompt for password on withdraw if password is set
This commit is contained in:
parent
9b873cf149
commit
8411ebc443
1 changed files with 39 additions and 26 deletions
|
@ -73,6 +73,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
private final XmrWalletService xmrWalletService;
|
private final XmrWalletService xmrWalletService;
|
||||||
private final TradeManager tradeManager;
|
private final TradeManager tradeManager;
|
||||||
private final P2PService p2PService;
|
private final P2PService p2PService;
|
||||||
|
private final WalletPasswordWindow walletPasswordWindow;
|
||||||
private XmrBalanceListener balanceListener;
|
private XmrBalanceListener balanceListener;
|
||||||
private BigInteger amount = BigInteger.valueOf(0);
|
private BigInteger amount = BigInteger.valueOf(0);
|
||||||
private ChangeListener<String> amountListener;
|
private ChangeListener<String> amountListener;
|
||||||
|
@ -96,6 +97,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
this.xmrWalletService = xmrWalletService;
|
this.xmrWalletService = xmrWalletService;
|
||||||
this.tradeManager = tradeManager;
|
this.tradeManager = tradeManager;
|
||||||
this.p2PService = p2PService;
|
this.p2PService = p2PService;
|
||||||
|
this.walletPasswordWindow = walletPasswordWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -215,33 +217,19 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
HavenoUtils.formatXmr(receiverAmount, true));
|
HavenoUtils.formatXmr(receiverAmount, true));
|
||||||
|
|
||||||
// popup confirmation message
|
// popup confirmation message
|
||||||
new Popup().headLine(Res.get("funds.withdrawal.confirmWithdrawalRequest"))
|
Popup popup = new Popup();
|
||||||
|
popup.headLine(Res.get("funds.withdrawal.confirmWithdrawalRequest"))
|
||||||
.confirmation(messageText)
|
.confirmation(messageText)
|
||||||
.actionButtonText(Res.get("shared.yes"))
|
.actionButtonText(Res.get("shared.yes"))
|
||||||
.onAction(() -> {
|
.onAction(() -> {
|
||||||
|
if (xmrWalletService.isWalletEncrypted()) {
|
||||||
// relay tx
|
walletPasswordWindow.headLine(Res.get("walletPasswordWindow.headline")).onSuccess(() -> {
|
||||||
try {
|
relayTx(tx, withdrawToAddress, amount, fee);
|
||||||
xmrWalletService.getWallet().relayTx(tx);
|
}).onClose(() -> {
|
||||||
xmrWalletService.getWallet().setTxNote(tx.getHash(), withdrawMemoTextField.getText()); // TODO (monero-java): tx note does not persist when tx created then relayed
|
popup.hide();
|
||||||
String key = "showTransactionSent";
|
}).hideForgotPasswordButton().show();
|
||||||
if (DontShowAgainLookup.showAgain(key)) {
|
} else {
|
||||||
new TxDetails(tx.getHash(), withdrawToAddress, HavenoUtils.formatXmr(receiverAmount, true), HavenoUtils.formatXmr(fee, true), xmrWalletService.getWallet().getTxNote(tx.getHash()))
|
relayTx(tx, withdrawToAddress, amount, fee);
|
||||||
.dontShowAgainId(key)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
log.debug("onWithdraw onSuccess tx ID:{}", tx.getHash());
|
|
||||||
|
|
||||||
List<Trade> trades = new ArrayList<>(tradeManager.getObservableList());
|
|
||||||
trades.stream()
|
|
||||||
.filter(Trade::isPayoutPublished)
|
|
||||||
.forEach(trade -> xmrWalletService.getAddressEntry(trade.getId(), XmrAddressEntry.Context.TRADE_PAYOUT)
|
|
||||||
.ifPresent(addressEntry -> {
|
|
||||||
if (xmrWalletService.getBalanceForAddress(addressEntry.getAddressString()).compareTo(BigInteger.valueOf(0)) == 0)
|
|
||||||
tradeManager.onTradeCompleted(trade);
|
|
||||||
}));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.closeButtonText(Res.get("shared.cancel"))
|
.closeButtonText(Res.get("shared.cancel"))
|
||||||
|
@ -250,13 +238,38 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||||
if (e.getMessage().contains("enough")) new Popup().warning(Res.get("funds.withdrawal.warn.amountExceeds")).show();
|
if (e.getMessage().contains("enough")) new Popup().warning(Res.get("funds.withdrawal.warn.amountExceeds")).show();
|
||||||
else {
|
else {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error(e.toString());
|
new Popup().warning(e.getMessage()).show();
|
||||||
new Popup().warning(e.toString()).show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void relayTx(MoneroTxWallet tx, String withdrawToAddress, BigInteger receiverAmount, BigInteger fee) {
|
||||||
|
try {
|
||||||
|
xmrWalletService.getWallet().relayTx(tx);
|
||||||
|
xmrWalletService.getWallet().setTxNote(tx.getHash(), withdrawMemoTextField.getText()); // TODO (monero-java): tx note does not persist when tx created then relayed
|
||||||
|
String key = "showTransactionSent";
|
||||||
|
if (DontShowAgainLookup.showAgain(key)) {
|
||||||
|
new TxDetails(tx.getHash(), withdrawToAddress, HavenoUtils.formatXmr(receiverAmount, true), HavenoUtils.formatXmr(fee, true), xmrWalletService.getWallet().getTxNote(tx.getHash()))
|
||||||
|
.dontShowAgainId(key)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
log.debug("onWithdraw onSuccess tx ID:{}", tx.getHash());
|
||||||
|
|
||||||
|
// TODO: remove this?
|
||||||
|
List<Trade> trades = new ArrayList<>(tradeManager.getObservableList());
|
||||||
|
trades.stream()
|
||||||
|
.filter(Trade::isPayoutPublished)
|
||||||
|
.forEach(trade -> xmrWalletService.getAddressEntry(trade.getId(), XmrAddressEntry.Context.TRADE_PAYOUT)
|
||||||
|
.ifPresent(addressEntry -> {
|
||||||
|
if (xmrWalletService.getBalanceForAddress(addressEntry.getAddressString()).compareTo(BigInteger.valueOf(0)) == 0)
|
||||||
|
tradeManager.onTradeCompleted(trade);
|
||||||
|
}));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Private
|
// Private
|
||||||
|
|
Loading…
Reference in a new issue