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 doEmptyWallet(KeyParameter aesKey) {
   emptyWalletButton.setDisable(true);
   try {
     walletService.emptyWallet(
         addressInputTextField.getText(),
         aesKey,
         () -> {
           closeButton.setText("Close");
           addressTextField.setText(
               formatter.formatCoinWithCode(walletService.getAvailableBalance()));
           emptyWalletButton.setDisable(true);
           log.debug("wallet empty successful");
           FxTimer.runLater(
               Duration.ofMillis(Transitions.DEFAULT_DURATION),
               () ->
                   new Popup()
                       .information("The balance of your wallet was successfully transferred.")
                       .onClose(() -> blurAgain())
                       .show());
         },
         (errorMessage) -> {
           emptyWalletButton.setDisable(false);
           log.debug("wallet empty failed " + errorMessage);
         });
   } catch (InsufficientMoneyException | AddressFormatException e1) {
     e1.printStackTrace();
     log.error(e1.getMessage());
     emptyWalletButton.setDisable(false);
   }
 }
示例#3
0
 @Override
 protected void autoFillNameTextField() {
   if (autoFillCheckBox != null && autoFillCheckBox.isSelected()) {
     String accountNr = accountNrInputTextField.getText();
     accountNr = accountNr.substring(0, Math.min(5, accountNr.length())) + "...";
     String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
     accountNameTextField.setText(method.concat(", ").concat(accountNr));
   }
 }