From d81b8680499a02b10b24e312201474cbae83c4c3 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 31 Jul 2025 11:47:43 +0200 Subject: [PATCH] add any dns payment instructions from loaded psbts if not already cached --- .../sparrowwallet/sparrow/AppController.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index b05f2a3e..84aa0060 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -3,13 +3,13 @@ package com.sparrowwallet.sparrow; import com.beust.jcommander.JCommander; import com.google.common.eventbus.Subscribe; import com.sparrowwallet.drongo.*; +import com.sparrowwallet.drongo.address.Address; import com.sparrowwallet.drongo.crypto.*; +import com.sparrowwallet.drongo.dns.DnsPayment; +import com.sparrowwallet.drongo.dns.DnsPaymentCache; import com.sparrowwallet.drongo.policy.PolicyType; import com.sparrowwallet.drongo.protocol.*; -import com.sparrowwallet.drongo.psbt.PSBT; -import com.sparrowwallet.drongo.psbt.PSBTInput; -import com.sparrowwallet.drongo.psbt.PSBTParseException; -import com.sparrowwallet.drongo.psbt.PSBTSignatureException; +import com.sparrowwallet.drongo.psbt.*; import com.sparrowwallet.drongo.wallet.*; import com.sparrowwallet.hummingbird.UR; import com.sparrowwallet.hummingbird.registry.CryptoPSBT; @@ -1916,6 +1916,21 @@ public class AppController implements Initializable { } } + //Add DNS payment information if not already cached + for(PSBTOutput psbtOutput : psbt.getPsbtOutputs()) { + if(psbtOutput.getDnssecProof() != null && !psbtOutput.getDnssecProof().isEmpty() && psbtOutput.getScript() != null) { + Address address = psbtOutput.getScript().getToAddress(); + if(address != null && DnsPaymentCache.getDnsPayment(address) == null) { + try { + Optional optDnsPayment = psbtOutput.getDnsPayment(); + optDnsPayment.ifPresent(dnsPayment -> DnsPaymentCache.putDnsPayment(address, dnsPayment)); + } catch(Exception e) { + log.debug("Error resolving DNS payment", e); + } + } + } + } + Window psbtWalletWindow = AppServices.get().getWindowForPSBT(psbt); if(psbtWalletWindow != null && !tabs.getScene().getWindow().equals(psbtWalletWindow)) { EventManager.get().post(new ViewPSBTEvent(psbtWalletWindow, name, file, psbt));