Search in sources :

Example 1 with AddressFormatException

use of org.bitcoinj.core.AddressFormatException in project bitsquare by bitsquare.

the class AltCoinAddressValidator method validate.

@Override
public ValidationResult validate(String input) {
    ValidationResult validationResult = super.validate(input);
    if (!validationResult.isValid || currencyCode == null) {
        return validationResult;
    } else {
        // Validation: 
        // 1: With a regex checking the correct structure of an address 
        // 2: If the address contains a checksum, verify the checksum
        ValidationResult wrongChecksum = new ValidationResult(false, "Address validation failed because checksum was not correct.");
        ValidationResult regexTestFailed = new ValidationResult(false, "Address validation failed because it does not match the structure of a " + currencyCode + " address.");
        switch(currencyCode) {
            case "ETH":
                // https://github.com/ethereum/web3.js/blob/master/lib/utils/utils.js#L403
                if (!input.matches("^(0x)?[0-9a-fA-F]{40}$"))
                    return regexTestFailed;
                else
                    return new ValidationResult(true);
            // Example for BTC, though for BTC we use the BitcoinJ library address check
            case "BTC":
                // taken form: https://stackoverflow.com/questions/21683680/regex-to-match-bitcoin-addresses
                if (input.matches("^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
                    if (verifyChecksum(input))
                        try {
                            new Address(MainNetParams.get(), input);
                            return new ValidationResult(true);
                        } catch (AddressFormatException e) {
                            return new ValidationResult(false, getErrorMessage(e));
                        }
                    else
                        return wrongChecksum;
                } else {
                    return regexTestFailed;
                }
            case "PIVX":
                if (input.matches("^[D][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
                    if (verifyChecksum(input)) {
                        try {
                            new Address(PivxParams.get(), input);
                            return new ValidationResult(true);
                        } catch (AddressFormatException e) {
                            return new ValidationResult(false, getErrorMessage(e));
                        }
                    } else {
                        return wrongChecksum;
                    }
                } else {
                    return regexTestFailed;
                }
            case "IOP":
                if (input.matches("^[p][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
                    if (verifyChecksum(input)) {
                        try {
                            new Address(IOPParams.get(), input);
                            return new ValidationResult(true);
                        } catch (AddressFormatException e) {
                            return new ValidationResult(false, getErrorMessage(e));
                        }
                    } else {
                        return wrongChecksum;
                    }
                } else {
                    return regexTestFailed;
                }
            case "888":
                if (input.matches("^[83][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
                    if (OctocoinAddressValidator.ValidateAddress(input)) {
                        try {
                            new Address(OctocoinParams.get(), input);
                            return new ValidationResult(true);
                        } catch (AddressFormatException e) {
                            return new ValidationResult(false, getErrorMessage(e));
                        }
                    } else {
                        return wrongChecksum;
                    }
                } else {
                    return regexTestFailed;
                }
            case "ZEC":
                // We only support t addresses (transparent transactions)
                if (input.startsWith("t"))
                    return validationResult;
                else
                    return new ValidationResult(false, "ZEC address need to start with t. Addresses starting with z are not supported.");
            /*case "XTO":
                    if (input.matches("^[T2][a-km-zA-HJ-NP-Z1-9]{25,34}$")) {
                        if (verifyChecksum(input))
                            try {
                                new Address(MainNetParams.get(), input);
                                return new ValidationResult(true);
                            } catch (AddressFormatException e) {
                                return new ValidationResult(false, getErrorMessage(e));
                            }
                        else
                            return wrongChecksum;
                    } else {
                        return regexTestFailed;
                    }*/
            case "GBYTE":
                return ByteballAddressValidator.validate(input);
            case "NXT":
                if (!input.startsWith("NXT-") || !input.equals(input.toUpperCase())) {
                    return regexTestFailed;
                }
                try {
                    long accountId = NxtReedSolomon.decode(input.substring(4));
                    return new ValidationResult(accountId != 0);
                } catch (NxtReedSolomon.DecodeException e) {
                    return wrongChecksum;
                }
            default:
                log.debug("Validation for AltCoinAddress not implemented yet. currencyCode:" + currencyCode);
                return validationResult;
        }
    }
}
Also used : AddressFormatException(org.bitcoinj.core.AddressFormatException) NxtReedSolomon(io.bitsquare.gui.util.validation.altcoins.NxtReedSolomon) Address(org.bitcoinj.core.Address)

Example 2 with AddressFormatException

use of org.bitcoinj.core.AddressFormatException in project bitsquare by bitsquare.

the class SpendFromDepositTxWindow method addContent.

private void addContent() {
    InputTextField depositTxHex = addLabelInputTextField(gridPane, ++rowIndex, "depositTxHex:").second;
    InputTextField buyerPayoutAmount = addLabelInputTextField(gridPane, ++rowIndex, "buyerPayoutAmount:").second;
    InputTextField sellerPayoutAmount = addLabelInputTextField(gridPane, ++rowIndex, "sellerPayoutAmount:").second;
    InputTextField arbitratorPayoutAmount = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorPayoutAmount:").second;
    InputTextField buyerAddressString = addLabelInputTextField(gridPane, ++rowIndex, "buyerAddressString:").second;
    InputTextField sellerAddressString = addLabelInputTextField(gridPane, ++rowIndex, "sellerAddressString:").second;
    InputTextField arbitratorAddressString = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorAddressString:").second;
    InputTextField buyerPrivateKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "buyerPrivateKeyAsHex:").second;
    InputTextField sellerPrivateKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "sellerPrivateKeyAsHex:").second;
    InputTextField arbitratorPrivateKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorPrivateKeyAsHex:").second;
    InputTextField buyerPubKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "buyerPubKeyAsHex:").second;
    InputTextField sellerPubKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "sellerPubKeyAsHex:").second;
    InputTextField arbitratorPubKeyAsHex = addLabelInputTextField(gridPane, ++rowIndex, "arbitratorPubKeyAsHex:").second;
    InputTextField P2SHMultiSigOutputScript = addLabelInputTextField(gridPane, ++rowIndex, "P2SHMultiSigOutputScript:").second;
    // Notes: 
    // Open with alt+g and enable DEV mode
    // Priv key is only visible if pw protection is removed (wallet details data (alt+j))
    // Take P2SHMultiSigOutputScript from depositTx in blockexplorer 
    // Take missing buyerPubKeyAsHex and sellerPubKeyAsHex from contract data!
    // Lookup sellerPrivateKeyAsHex associated with sellerPubKeyAsHex (or buyers) in wallet details data 
    // sellerPubKeys/buyerPubKeys are auto generated if used the fields below
    // Never set the priv arbitr. key here!
    depositTxHex.setText("");
    P2SHMultiSigOutputScript.setText("");
    buyerPayoutAmount.setText("1.03");
    sellerPayoutAmount.setText("0.03");
    arbitratorPayoutAmount.setText("0");
    buyerAddressString.setText("");
    buyerPubKeyAsHex.setText("");
    buyerPrivateKeyAsHex.setText("");
    sellerAddressString.setText("");
    sellerPubKeyAsHex.setText("");
    sellerPrivateKeyAsHex.setText("");
    //4.9 (pkfcmj42c6es6tjt.onion)
    // arbitratorAddressString.setText("19xdeiQM2Hn2M2wbpT5imcYWzqhiSDHPy4");
    // arbitratorPubKeyAsHex.setText("02c62e794fe67f3a2115e2de4757143ff7f27bdf38aa4ae58a3595baa6d676875b");
    // 4.2 (ntjhaj27rylxwvnp.onion)
    arbitratorAddressString.setText("1FdFzBazmHQxbUbdCUJwuCtR37DrZrEobu");
    arbitratorPubKeyAsHex.setText("030fdc2ebc297df4047442f6079f1ce3b7d1938a41f88bd11497545cc94fcfd315");
    actionButtonText("Sign and publish transaction");
    FutureCallback<Transaction> callback = new FutureCallback<Transaction>() {

        @Override
        public void onSuccess(@Nullable Transaction result) {
            log.error("onSuccess");
            UserThread.execute(() -> {
                String txId = result != null ? result.getHashAsString() : "null";
                new Popup<>().information("Transaction successful published. Transaction ID: " + txId).show();
            });
        }

        @Override
        public void onFailure(Throwable t) {
            log.error(t.toString());
            log.error("onFailure");
            UserThread.execute(() -> new Popup<>().warning(t.toString()).show());
        }
    };
    onAction(() -> {
        try {
            tradeWalletService.emergencySignAndPublishPayoutTx(depositTxHex.getText(), Coin.parseCoin(buyerPayoutAmount.getText()), Coin.parseCoin(sellerPayoutAmount.getText()), Coin.parseCoin(arbitratorPayoutAmount.getText()), buyerAddressString.getText(), sellerAddressString.getText(), arbitratorAddressString.getText(), buyerPrivateKeyAsHex.getText(), sellerPrivateKeyAsHex.getText(), arbitratorPrivateKeyAsHex.getText(), buyerPubKeyAsHex.getText(), sellerPubKeyAsHex.getText(), arbitratorPubKeyAsHex.getText(), P2SHMultiSigOutputScript.getText(), callback);
        } catch (AddressFormatException | WalletException | TransactionVerificationException e) {
            log.error(e.toString());
            e.printStackTrace();
            UserThread.execute(() -> new Popup<>().warning(e.toString()).show());
        }
    });
}
Also used : WalletException(io.bitsquare.btc.exceptions.WalletException) AddressFormatException(org.bitcoinj.core.AddressFormatException) TransactionVerificationException(io.bitsquare.btc.exceptions.TransactionVerificationException) FormBuilder.addLabelInputTextField(io.bitsquare.gui.util.FormBuilder.addLabelInputTextField) InputTextField(io.bitsquare.gui.components.InputTextField) Transaction(org.bitcoinj.core.Transaction) Popup(io.bitsquare.gui.main.overlays.popups.Popup) FutureCallback(com.google.common.util.concurrent.FutureCallback) Nullable(javax.annotation.Nullable)

Example 3 with AddressFormatException

use of org.bitcoinj.core.AddressFormatException in project bitsquare by bitsquare.

the class DisputeSummaryWindow method addButtons.

private void addButtons(Contract contract) {
    Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(gridPane, ++rowIndex, "Close ticket", "Cancel");
    Button closeTicketButton = tuple.first;
    closeTicketButton.disableProperty().bind(Bindings.createBooleanBinding(() -> tradeAmountToggleGroup.getSelectedToggle() == null || summaryNotesTextArea.getText() == null || summaryNotesTextArea.getText().length() == 0 || !isPayoutAmountValid(), tradeAmountToggleGroup.selectedToggleProperty(), summaryNotesTextArea.textProperty(), buyerPayoutAmountInputTextField.textProperty(), sellerPayoutAmountInputTextField.textProperty(), arbitratorPayoutAmountInputTextField.textProperty()));
    Button cancelButton = tuple.second;
    final Dispute finalPeersDispute = peersDisputeOptional.get();
    closeTicketButton.setOnAction(e -> {
        if (dispute.getDepositTxSerialized() != null) {
            try {
                AddressEntry arbitratorAddressEntry = walletService.getOrCreateAddressEntry(AddressEntry.Context.ARBITRATOR);
                disputeResult.setArbitratorAddressAsString(arbitratorAddressEntry.getAddressString());
                disputeResult.setArbitratorPubKey(arbitratorAddressEntry.getPubKey());
                byte[] arbitratorSignature = tradeWalletService.arbitratorSignsDisputedPayoutTx(dispute.getDepositTxSerialized(), disputeResult.getBuyerPayoutAmount(), disputeResult.getSellerPayoutAmount(), disputeResult.getArbitratorPayoutAmount(), contract.getBuyerPayoutAddressString(), contract.getSellerPayoutAddressString(), arbitratorAddressEntry.getAddressString(), arbitratorAddressEntry.getKeyPair(), contract.getBuyerMultiSigPubKey(), contract.getSellerMultiSigPubKey(), arbitratorAddressEntry.getPubKey());
                disputeResult.setArbitratorSignature(arbitratorSignature);
                closeTicketButton.disableProperty().unbind();
                dispute.setDisputeResult(disputeResult);
                disputeResult.setLoserIsPublisher(isLoserPublisherCheckBox.isSelected());
                disputeResult.setCloseDate(new Date());
                String text = "Ticket closed on " + formatter.formatDateTime(disputeResult.getCloseDate()) + "\n\nSummary:" + "\n" + role + " delivered tamper proof evidence: " + formatter.booleanToYesNo(disputeResult.tamperProofEvidenceProperty().get()) + "\n" + role + " did ID verification: " + formatter.booleanToYesNo(disputeResult.idVerificationProperty().get()) + "\n" + role + " did screencast or video: " + formatter.booleanToYesNo(disputeResult.screenCastProperty().get()) + "\nPayout amount for BTC buyer: " + formatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount()) + "\nPayout amount for BTC seller: " + formatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount()) + "\nArbitrator's dispute fee: " + formatter.formatCoinWithCode(disputeResult.getArbitratorPayoutAmount()) + "\n\nSummary notes:\n" + disputeResult.summaryNotesProperty().get();
                dispute.setIsClosed(true);
                disputeManager.sendDisputeResultMessage(disputeResult, dispute, text);
                if (!finalPeersDispute.isClosed())
                    UserThread.runAfter(() -> new Popup().attention("You need to close also the trading peers ticket!").show(), Transitions.DEFAULT_DURATION, TimeUnit.MILLISECONDS);
                hide();
                finalizeDisputeHandlerOptional.ifPresent(finalizeDisputeHandler -> finalizeDisputeHandler.run());
            } catch (AddressFormatException | TransactionVerificationException e2) {
                e2.printStackTrace();
            }
        } else {
            log.warn("dispute.getDepositTxSerialized is null");
        }
    });
    cancelButton.setOnAction(e -> {
        dispute.setDisputeResult(disputeResult);
        hide();
    });
}
Also used : AddressFormatException(org.bitcoinj.core.AddressFormatException) AddressEntry(io.bitsquare.btc.AddressEntry) TransactionVerificationException(io.bitsquare.btc.exceptions.TransactionVerificationException) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Dispute(io.bitsquare.arbitration.Dispute) Date(java.util.Date)

Example 4 with AddressFormatException

use of org.bitcoinj.core.AddressFormatException in project bitsquare by bitsquare.

the class DisputeManager method onDisputeResultMessage.

// We get that message at both peers. The dispute object is in context of the trader
private void onDisputeResultMessage(DisputeResultMessage disputeResultMessage) {
    DisputeResult disputeResult = disputeResultMessage.disputeResult;
    if (!isArbitrator(disputeResult)) {
        final String tradeId = disputeResult.tradeId;
        Optional<Dispute> disputeOptional = findDispute(tradeId, disputeResult.traderId);
        final String uid = disputeResultMessage.getUID();
        if (disputeOptional.isPresent()) {
            cleanupRetryMap(uid);
            Dispute dispute = disputeOptional.get();
            DisputeCommunicationMessage disputeCommunicationMessage = disputeResult.getDisputeCommunicationMessage();
            if (!dispute.getDisputeCommunicationMessagesAsObservableList().contains(disputeCommunicationMessage))
                dispute.addDisputeMessage(disputeCommunicationMessage);
            else
                log.warn("We got a dispute mail msg what we have already stored. TradeId = " + disputeCommunicationMessage.getTradeId());
            dispute.setIsClosed(true);
            if (dispute.disputeResultProperty().get() != null)
                log.warn("We got already a dispute result. That should only happen if a dispute needs to be closed " + "again because the first close did not succeed. TradeId = " + tradeId);
            dispute.setDisputeResult(disputeResult);
            // We need to avoid publishing the tx from both traders as it would create problems with zero confirmation withdrawals
            // There would be different transactions if both sign and publish (signers: once buyer+arb, once seller+arb)
            // The tx publisher is the winner or in case both get 50% the buyer, as the buyer has more inventive to publish the tx as he receives 
            // more BTC as he has deposited
            final Contract contract = dispute.getContract();
            boolean isBuyer = keyRing.getPubKeyRing().equals(contract.getBuyerPubKeyRing());
            DisputeResult.Winner publisher = disputeResult.getWinner();
            // Default isLoserPublisher is set to false
            if (disputeResult.isLoserPublisher()) {
                // we invert the logic
                if (publisher == DisputeResult.Winner.BUYER)
                    publisher = DisputeResult.Winner.SELLER;
                else if (publisher == DisputeResult.Winner.SELLER)
                    publisher = DisputeResult.Winner.BUYER;
            }
            if ((isBuyer && publisher == DisputeResult.Winner.BUYER) || (!isBuyer && publisher == DisputeResult.Winner.SELLER) || (isBuyer && publisher == DisputeResult.Winner.STALE_MATE)) {
                final Optional<Trade> tradeOptional = tradeManager.getTradeById(tradeId);
                Transaction payoutTx = null;
                if (tradeOptional.isPresent()) {
                    payoutTx = tradeOptional.get().getPayoutTx();
                } else {
                    final Optional<Tradable> tradableOptional = closedTradableManager.getTradableById(tradeId);
                    if (tradableOptional.isPresent() && tradableOptional.get() instanceof Trade) {
                        payoutTx = ((Trade) tradableOptional.get()).getPayoutTx();
                    }
                }
                if (payoutTx == null) {
                    if (dispute.getDepositTxSerialized() != null) {
                        try {
                            log.debug("do payout Transaction ");
                            AddressEntry multiSigAddressEntry = walletService.getOrCreateAddressEntry(dispute.getTradeId(), AddressEntry.Context.MULTI_SIG);
                            Transaction signedDisputedPayoutTx = tradeWalletService.traderSignAndFinalizeDisputedPayoutTx(dispute.getDepositTxSerialized(), disputeResult.getArbitratorSignature(), disputeResult.getBuyerPayoutAmount(), disputeResult.getSellerPayoutAmount(), disputeResult.getArbitratorPayoutAmount(), contract.getBuyerPayoutAddressString(), contract.getSellerPayoutAddressString(), disputeResult.getArbitratorAddressAsString(), multiSigAddressEntry.getKeyPair(), contract.getBuyerMultiSigPubKey(), contract.getSellerMultiSigPubKey(), disputeResult.getArbitratorPubKey());
                            Transaction committedDisputedPayoutTx = tradeWalletService.addTransactionToWallet(signedDisputedPayoutTx);
                            log.debug("broadcast committedDisputedPayoutTx");
                            tradeWalletService.broadcastTx(committedDisputedPayoutTx, new FutureCallback<Transaction>() {

                                @Override
                                public void onSuccess(Transaction transaction) {
                                    log.debug("BroadcastTx succeeded. Transaction:" + transaction);
                                    // after successful publish we send peer the tx
                                    dispute.setDisputePayoutTxId(transaction.getHashAsString());
                                    sendPeerPublishedPayoutTxMessage(transaction, dispute, contract);
                                    // set state after payout as we call swapTradeEntryToAvailableEntry 
                                    if (tradeManager.getTradeById(dispute.getTradeId()).isPresent())
                                        tradeManager.closeDisputedTrade(dispute.getTradeId());
                                    else {
                                        Optional<OpenOffer> openOfferOptional = openOfferManager.getOpenOfferById(dispute.getTradeId());
                                        if (openOfferOptional.isPresent())
                                            openOfferManager.closeOpenOffer(openOfferOptional.get().getOffer());
                                    }
                                }

                                @Override
                                public void onFailure(@NotNull Throwable t) {
                                    log.error(t.getMessage());
                                }
                            });
                        } catch (AddressFormatException | WalletException | TransactionVerificationException e) {
                            e.printStackTrace();
                            log.error("Error at traderSignAndFinalizeDisputedPayoutTx " + e.getMessage());
                        }
                    } else {
                        log.warn("DepositTx is null. TradeId = " + tradeId);
                    }
                } else {
                    log.warn("We got already a payout tx. That might be the case if the other peer did not get the " + "payout tx and opened a dispute. TradeId = " + tradeId);
                    dispute.setDisputePayoutTxId(payoutTx.getHashAsString());
                    sendPeerPublishedPayoutTxMessage(payoutTx, dispute, contract);
                }
            } else {
                log.trace("We don't publish the tx as we are not the winning party.");
                // Clean up tangling trades
                if (dispute.disputeResultProperty().get() != null && dispute.isClosed() && tradeManager.getTradeById(dispute.getTradeId()).isPresent())
                    tradeManager.closeDisputedTrade(dispute.getTradeId());
            }
        } else {
            log.debug("We got a dispute result msg but we don't have a matching dispute. " + "That might happen when we get the disputeResultMessage before the dispute was created. " + "We try again after 2 sec. to apply the disputeResultMessage. TradeId = " + tradeId);
            if (!delayMsgMap.containsKey(uid)) {
                // We delay2 sec. to be sure the comm. msg gets added first
                Timer timer = UserThread.runAfter(() -> onDisputeResultMessage(disputeResultMessage), 2);
                delayMsgMap.put(uid, timer);
            } else {
                log.warn("We got a dispute result msg after we already repeated to apply the message after a delay. " + "That should never happen. TradeId = " + tradeId);
            }
        }
    } else {
        log.error("Arbitrator received disputeResultMessage. That must never happen.");
    }
}
Also used : WalletException(io.bitsquare.btc.exceptions.WalletException) AddressFormatException(org.bitcoinj.core.AddressFormatException) Optional(java.util.Optional) AddressEntry(io.bitsquare.btc.AddressEntry) TransactionVerificationException(io.bitsquare.btc.exceptions.TransactionVerificationException) Tradable(io.bitsquare.trade.Tradable) Trade(io.bitsquare.trade.Trade) Transaction(org.bitcoinj.core.Transaction) Timer(io.bitsquare.common.Timer) Contract(io.bitsquare.trade.Contract)

Example 5 with AddressFormatException

use of org.bitcoinj.core.AddressFormatException in project bitsquare by bitsquare.

the class BuyerStep5View method reviewWithdrawal.

private void reviewWithdrawal() {
    Coin senderAmount = trade.getPayoutAmount();
    WalletService walletService = model.dataModel.walletService;
    AddressEntry fromAddressesEntry = walletService.getOrCreateAddressEntry(trade.getId(), AddressEntry.Context.TRADE_PAYOUT);
    String fromAddresses = fromAddressesEntry.getAddressString();
    String toAddresses = withdrawAddressTextField.getText();
    // TODO at some error situation it can be tha the funds are already paid out and we get stuck here
    // need handling to remove the trade (planned for next release)
    Coin balance = walletService.getBalanceForAddress(fromAddressesEntry.getAddress());
    try {
        Coin requiredFee = walletService.getRequiredFee(fromAddresses, toAddresses, senderAmount, AddressEntry.Context.TRADE_PAYOUT);
        Coin receiverAmount = senderAmount.subtract(requiredFee);
        if (balance.isZero()) {
            new Popup().warning("Your funds have already been withdrawn.\nPlease check the transaction history.").show();
            model.dataModel.tradeManager.addTradeToClosedTrades(trade);
        } else {
            if (toAddresses.isEmpty()) {
                validateWithdrawAddress();
            } else if (Restrictions.isAboveFixedTxFeeForTradesAndDust(senderAmount)) {
                if (DevFlags.DEV_MODE) {
                    doWithdrawal(receiverAmount);
                } else {
                    BSFormatter formatter = model.formatter;
                    String key = "reviewWithdrawalAtTradeComplete";
                    if (!DevFlags.DEV_MODE && preferences.showAgain(key)) {
                        new Popup().headLine("Confirm withdrawal request").confirmation("Sending: " + formatter.formatCoinWithCode(senderAmount) + "\n" + "From address: " + fromAddresses + "\n" + "To receiving address: " + toAddresses + ".\n" + "Required transaction fee is: " + formatter.formatCoinWithCode(requiredFee) + "\n\n" + "The recipient will receive: " + formatter.formatCoinWithCode(receiverAmount) + "\n\n" + "Are you sure you want to proceed with the withdrawal?").closeButtonText("Cancel").onClose(() -> {
                            useSavingsWalletButton.setDisable(false);
                            withdrawToExternalWalletButton.setDisable(false);
                        }).actionButtonText("Yes").onAction(() -> doWithdrawal(receiverAmount)).dontShowAgainId(key, preferences).show();
                    } else {
                        doWithdrawal(receiverAmount);
                    }
                }
            } else {
                new Popup().warning("The amount to transfer is lower than the transaction fee and the min. possible tx value (dust).").show();
            }
        }
    } catch (AddressFormatException e) {
        validateWithdrawAddress();
    } catch (AddressEntryException e) {
        log.error(e.getMessage());
    }
}
Also used : Coin(org.bitcoinj.core.Coin) AddressFormatException(org.bitcoinj.core.AddressFormatException) AddressEntryException(io.bitsquare.btc.AddressEntryException) AddressEntry(io.bitsquare.btc.AddressEntry) Popup(io.bitsquare.gui.main.overlays.popups.Popup) BSFormatter(io.bitsquare.gui.util.BSFormatter) WalletService(io.bitsquare.btc.WalletService)

Aggregations

AddressFormatException (org.bitcoinj.core.AddressFormatException)5 AddressEntry (io.bitsquare.btc.AddressEntry)3 TransactionVerificationException (io.bitsquare.btc.exceptions.TransactionVerificationException)3 Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 WalletException (io.bitsquare.btc.exceptions.WalletException)2 Transaction (org.bitcoinj.core.Transaction)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Dispute (io.bitsquare.arbitration.Dispute)1 AddressEntryException (io.bitsquare.btc.AddressEntryException)1 WalletService (io.bitsquare.btc.WalletService)1 Timer (io.bitsquare.common.Timer)1 InputTextField (io.bitsquare.gui.components.InputTextField)1 BSFormatter (io.bitsquare.gui.util.BSFormatter)1 FormBuilder.addLabelInputTextField (io.bitsquare.gui.util.FormBuilder.addLabelInputTextField)1 NxtReedSolomon (io.bitsquare.gui.util.validation.altcoins.NxtReedSolomon)1 Contract (io.bitsquare.trade.Contract)1 Tradable (io.bitsquare.trade.Tradable)1 Trade (io.bitsquare.trade.Trade)1 Date (java.util.Date)1 Optional (java.util.Optional)1