Search in sources :

Example 1 with PayNymAddress

use of com.sparrowwallet.sparrow.paynym.PayNymAddress in project sparrow by sparrowwallet.

the class PaymentController method getRecipientAddress.

private Address getRecipientAddress() throws InvalidAddressException {
    if (payNymProperty.get() == null) {
        return Address.fromString(address.getText());
    }
    try {
        Wallet recipientBip47Wallet = getWalletForPayNym(payNymProperty.get());
        if (recipientBip47Wallet != null) {
            WalletNode sendNode = recipientBip47Wallet.getFreshNode(KeyPurpose.SEND);
            ECKey pubKey = sendNode.getPubKey();
            Address address = recipientBip47Wallet.getScriptType().getAddress(pubKey);
            if (sendController.getPaymentTabs().getTabs().size() > 1 || (getRecipientValueSats() != null && getRecipientValueSats() > getRecipientDustThreshold(address)) || maxButton.isSelected()) {
                return address;
            }
        }
    } catch (InvalidPaymentCodeException e) {
        log.error("Error creating payment code from PayNym", e);
    }
    return new PayNymAddress(payNymProperty.get());
}
Also used : InvalidPaymentCodeException(com.sparrowwallet.drongo.bip47.InvalidPaymentCodeException) PayNymAddress(com.sparrowwallet.sparrow.paynym.PayNymAddress) Address(com.sparrowwallet.drongo.address.Address) P2PKHAddress(com.sparrowwallet.drongo.address.P2PKHAddress) PayNymAddress(com.sparrowwallet.sparrow.paynym.PayNymAddress) ECKey(com.sparrowwallet.drongo.crypto.ECKey)

Aggregations

Address (com.sparrowwallet.drongo.address.Address)1 P2PKHAddress (com.sparrowwallet.drongo.address.P2PKHAddress)1 InvalidPaymentCodeException (com.sparrowwallet.drongo.bip47.InvalidPaymentCodeException)1 ECKey (com.sparrowwallet.drongo.crypto.ECKey)1 PayNymAddress (com.sparrowwallet.sparrow.paynym.PayNymAddress)1