private void addContent() { addMultilineLabel( gridPane, ++rowIndex, "Please use that only in emergency case if you cannot access your fund from the UI.\n" + "Before you use this tool, you should backup your data directory. After you have successfully transferred your wallet balance, remove" + " the db directory inside the data directory to start with a newly created and consistent data structure.\n" + "Please make a bug report on Github so that we can investigate what was causing the problem.", 10); Coin totalBalance = walletService.getAvailableBalance(); boolean isBalanceSufficient = totalBalance.compareTo(FeePolicy.TX_FEE) >= 0; addressTextField = addLabelTextField( gridPane, ++rowIndex, "Your available wallet balance:", formatter.formatCoinWithCode(totalBalance), 10) .second; Tuple2<Label, InputTextField> tuple = addLabelInputTextField(gridPane, ++rowIndex, "Your destination address:"); addressInputTextField = tuple.second; emptyWalletButton = new Button("Empty wallet"); emptyWalletButton.setDefaultButton(isBalanceSufficient); emptyWalletButton.setDisable( !isBalanceSufficient && addressInputTextField.getText().length() > 0); emptyWalletButton.setOnAction( e -> { if (addressInputTextField.getText().length() > 0 && isBalanceSufficient) { if (walletService.getWallet().isEncrypted()) { walletPasswordPopup .onClose(() -> blurAgain()) .onAesKey(aesKey -> doEmptyWallet(aesKey)) .show(); } else { doEmptyWallet(null); } } }); closeButton = new Button("Cancel"); closeButton.setOnAction( e -> { hide(); closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run()); }); HBox hBox = new HBox(); hBox.setSpacing(10); GridPane.setRowIndex(hBox, ++rowIndex); GridPane.setColumnIndex(hBox, 1); hBox.getChildren().addAll(emptyWalletButton, closeButton); gridPane.getChildren().add(hBox); GridPane.setMargin(hBox, new Insets(10, 0, 0, 0)); }
private void tryOpenDispute(boolean isSupportTicket) { if (trade != null) { Transaction depositTx = trade.getDepositTx(); if (depositTx != null) { doOpenDispute(isSupportTicket, trade.getDepositTx()); } else { log.warn("Trade.depositTx is null. We try to find the tx in our wallet."); List<Transaction> candidates = new ArrayList<>(); List<Transaction> transactions = walletService.getWallet().getRecentTransactions(100, true); transactions .stream() .forEach( transaction -> { Coin valueSentFromMe = transaction.getValueSentFromMe(walletService.getWallet()); if (!valueSentFromMe.isZero()) { // spending tx for (TransactionOutput transactionOutput : transaction.getOutputs()) { if (!transactionOutput.isMine(walletService.getWallet())) { if (transactionOutput.getScriptPubKey().isPayToScriptHash()) { // MS tx candidates.add(transaction); } } } } }); if (candidates.size() == 1) doOpenDispute(isSupportTicket, candidates.get(0)); else if (candidates.size() > 1) new SelectDepositTxPopup() .transactions(candidates) .onSelect( transaction -> { doOpenDispute(isSupportTicket, transaction); }) .closeButtonText("Cancel") .show(); else log.error("Trade.depositTx is null and we did not find any MultiSig transaction."); } } else { log.error("Trade is null"); } }
void onWithdrawRequest(String toAddress) { checkNotNull(trade, "trade must not be null"); if (walletService.getWallet().isEncrypted()) walletPasswordPopup.show().onAesKey(aesKey -> doWithdrawRequest(toAddress, aesKey)); else doWithdrawRequest(toAddress, null); }