From 25db034c6276dc9d56daae980fd17699bad232d1 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 2 Oct 2026 13:23:47 +0200 Subject: [PATCH] always rebuild the send transaction when a human readable name is pasted over the pay to address --- .../sparrow/wallet/PaymentController.java | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java index 5ab32ad6..6beb88b0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java @@ -194,16 +194,15 @@ public class PaymentController extends WalletFormController implements Initializ //ignore, not a URI } + //A name is not a recipient until it has resolved, which it may never do. Whatever becomes of it, the transaction is rebuilt below, as the + //one already created is for the recipient the name has replaced Optional optDnsPaymentHrn = DnsPayment.getHrn(newValue); if(optDnsPaymentHrn.isPresent()) { String dnsPaymentHrn = optDnsPaymentHrn.get(); DnsPayment cachedDnsPayment = DnsPaymentCache.getDnsPayment(dnsPaymentHrn); if(cachedDnsPayment != null) { setDnsPayment(cachedDnsPayment); - return; - } - - if(Config.get().hasServer() && !AppServices.isConnected() && !AppServices.isConnecting()) { + } else if(Config.get().hasServer() && !AppServices.isConnected() && !AppServices.isConnecting()) { if(Config.get().getConnectToResolve() == null || Config.get().getConnectToResolve() == Boolean.FALSE) { Platform.runLater(() -> { ConfirmationAlert confirmationAlert = new ConfirmationAlert("Connect to resolve?", "You are currently offline. Connect to resolve the address?", ButtonType.NO, ButtonType.YES); @@ -218,23 +217,21 @@ public class PaymentController extends WalletFormController implements Initializ } else { Platform.runLater(() -> EventManager.get().post(new RequestConnectEvent())); } - return; + } else { + DnsPaymentService dnsPaymentService = new DnsPaymentService(dnsPaymentHrn); + dnsPaymentService.setOnSucceeded(_ -> { + if(isCurrentHrn(dnsPaymentHrn)) { + dnsPaymentService.getValue().ifPresent(dnsPayment -> setDnsPayment(dnsPayment)); + } + }); + dnsPaymentService.setOnFailed(failEvent -> { + Throwable exception = failEvent.getSource().getException(); + if(isCurrentHrn(dnsPaymentHrn) && exception != null && !(exception.getCause() instanceof TimeoutException)) { + AppServices.showErrorDialog("Validation failed for " + dnsPaymentHrn, Throwables.getRootCause(exception).getMessage()); + } + }); + dnsPaymentService.start(); } - - DnsPaymentService dnsPaymentService = new DnsPaymentService(dnsPaymentHrn); - dnsPaymentService.setOnSucceeded(_ -> { - if(isCurrentHrn(dnsPaymentHrn)) { - dnsPaymentService.getValue().ifPresent(dnsPayment -> setDnsPayment(dnsPayment)); - } - }); - dnsPaymentService.setOnFailed(failEvent -> { - Throwable exception = failEvent.getSource().getException(); - if(isCurrentHrn(dnsPaymentHrn) && exception != null && !(exception.getCause() instanceof TimeoutException)) { - AppServices.showErrorDialog("Validation failed for " + dnsPaymentHrn, Throwables.getRootCause(exception).getMessage()); - } - }); - dnsPaymentService.start(); - return; } if(sendController.getWalletForm().getWallet().hasPaymentCode()) {