only apply dns payment resolutions matching the currently entered recipient

This commit is contained in:
Craig Raw
2026-08-21 10:27:17 +02:00
parent bf0daae6cd
commit 185e0e8b69
2 changed files with 15 additions and 4 deletions
+1 -1
Submodule drongo updated: 23e092f556...4336bbd469
@@ -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);