From 185e0e8b69afefc698180b1b8cbbaa563d8f3436 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 21 Aug 2026 10:27:17 +0200 Subject: [PATCH] only apply dns payment resolutions matching the currently entered recipient --- drongo | 2 +- .../sparrow/wallet/PaymentController.java | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drongo b/drongo index 23e092f5..4336bbd4 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 23e092f556c4ae88576674965d806d49dfc11966 +Subproject commit 4336bbd469e9bdd91531f55ac0f2bdb3ca07efb4 diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java index 228ed481..e71c7da2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/PaymentController.java @@ -222,10 +222,15 @@ public class PaymentController extends WalletFormController implements Initializ } DnsPaymentService dnsPaymentService = new DnsPaymentService(dnsPaymentHrn); - dnsPaymentService.setOnSucceeded(_ -> dnsPaymentService.getValue().ifPresent(dnsPayment -> setDnsPayment(dnsPayment))); + dnsPaymentService.setOnSucceeded(_ -> { + if(isCurrentHrn(dnsPaymentHrn)) { + dnsPaymentService.getValue().ifPresent(dnsPayment -> setDnsPayment(dnsPayment)); + } + }); dnsPaymentService.setOnFailed(failEvent -> { - if(failEvent.getSource().getException() != null && !(failEvent.getSource().getException().getCause() instanceof TimeoutException)) { - AppServices.showErrorDialog("Validation failed for " + dnsPaymentHrn, Throwables.getRootCause(failEvent.getSource().getException()).getMessage()); + 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(); @@ -449,6 +454,12 @@ public class PaymentController extends WalletFormController implements Initializ } } + //Resolution is slow enough that several may be in flight at once, since every keystroke forming a valid hrn starts one. + //Only the hrn the address field currently holds may be applied - an earlier one landing later must not replace the recipient. + private boolean isCurrentHrn(String hrn) { + return DnsPayment.getHrn(address.getText()).filter(hrn::equals).isPresent(); + } + public void setDnsPayment(DnsPayment dnsPayment) { if(dnsPayment.hasAddress()) { DnsPaymentCache.putDnsPayment(dnsPayment.bitcoinURI().getAddress(), dnsPayment);