verify silent payment outputs against the open wallet providing all inputs when a psbt is exported or combined before finalizing
What changed, and why it matters
This commit fixes a gap in how Sparrow Wallet checks Silent Payment addresses when a partially-built transaction (PSBT) is exported or combined before it is finalized. Previously, the wallet only verified the Silent Payment output against the wallet that would eventually sign. If the PSBT had no signing wallet yet, the output could go unverified. The change makes the app also look at all currently open wallets and verify against the one that can prove all inputs, reducing the chance of paying to a wrong or attacker-controlled Silent Payment address.
Users who create or combine PSBTs with Silent Payment outputs should upgrade to a release containing this commit. Developers should review whether any other pre-finalization PSBT flows (e.g., loading, broadcasting, saving) also rely on signingWallet being non-null for Silent Payment verification.
Security signals we found
Silent Payment output verification bypass before PSBT finalization
PSBT combine/export code path previously lacked fallback wallet selection
Defensive fix expanding verification coverage rather than adding new crypto primitives
Evidence from the diff
The patch moves verifySilentPaymentScripts from AppController and HeadersController into AppServices as a static helper. The new implementation first tries the explicit signingWallet; if none is set but the PSBT contains Silent Payment outputs, it searches open wallets for one whose signing nodes cover all PSBT inputs, then verifies against that wallet. This covers cases where a PSBT is exported or combined before finalization, when signingWallet is null. The change is defensive and does not alter the underlying cryptographic verification logic.
Changed components
Sparrow Wallet desktop applicationPSBT combine and export flowsSilent Payment output verificationAppControllerAppServicesHeadersControllerInspect captured patch +18 / −16
### src/main/java/com/sparrowwallet/sparrow/AppController.java
@@ -2222,7 +2222,7 @@ private void handleTransactionMerge(TransactionTabData transactionTabData, PSBT
try {
PSBT combinedPsbt = currentPsbt.verifyCombinedSignatures(psbt);
//A combine can resolve a silent payment output script, which is only valid if the metadata provided with it proves the claimed address
- verifySilentPaymentScripts(transactionTabData.getTransactionData().getSigningWallet(), combinedPsbt);
+ AppServices.verifySilentPaymentScripts(transactionTabData.getTransactionData().getSigningWallet(), combinedPsbt);
currentPsbt.combine(psbt);
setTabName(tab, name);
EventManager.get().post(new PSBTCombinedEvent(currentPsbt));
@@ -2250,7 +2250,7 @@ private void handleTransactionMerge(TransactionTabData transactionTabData, PSBT
private boolean verifyPSBT(Wallet signingWallet, PSBT psbt) {
try {
- verifySilentPaymentScripts(signingWallet, psbt);
+ AppServices.verifySilentPaymentScripts(signingWallet, psbt);
} catch(InvalidSilentPaymentException e) {
showErrorDialog("Unverified Silent Payment Outputs", e.getMessage());
return false;
@@ -2259,12 +2259,6 @@ private boolean verifyPSBT(Wallet signingWallet, PSBT psbt) {
return true;
}
- private void verifySilentPaymentScripts(Wallet signingWallet, PSBT psbt) throws InvalidSilentPaymentException {
- if(signingWallet != null) {
- signingWallet.verifySilentPaymentScripts(psbt);
- }
- }
-
private boolean verifyTransactionContext(PSBT contextPsbt, Transaction transaction, PSBT psbt, String source) {
if(contextPsbt == null || matchesOpenTransactionTab(transaction, psbt)) {
return true;
### src/main/java/com/sparrowwallet/sparrow/AppServices.java
@@ -22,6 +22,7 @@
import com.sparrowwallet.drongo.protocol.Sha256Hash;
import com.sparrowwallet.drongo.protocol.Transaction;
import com.sparrowwallet.drongo.psbt.PSBT;
+import com.sparrowwallet.drongo.silentpayments.InvalidSilentPaymentException;
import com.sparrowwallet.drongo.uri.BitcoinURI;
import com.sparrowwallet.sparrow.control.TrayManager;
import com.sparrowwallet.sparrow.event.*;
@@ -788,6 +789,19 @@ public Map<Wallet, Storage> getOpenWallets() {
return openWallets;
}
+ public static void verifySilentPaymentScripts(Wallet signingWallet, PSBT psbt) throws InvalidSilentPaymentException {
+ if(signingWallet != null) {
+ signingWallet.verifySilentPaymentScripts(psbt);
+ } else if(psbt != null && psbt.hasSilentPaymentOutputs()) {
+ //A PSBT has no signing wallet until it is finalized, so its outputs are proven against the open wallet providing all of its inputs
+ Optional<Wallet> optInputWallet = get().getOpenWallets().keySet().stream()
+ .filter(wallet -> wallet.getSigningNodes(psbt).size() == psbt.getPsbtInputs().size()).findFirst();
+ if(optInputWallet.isPresent()) {
+ optInputWallet.get().verifySilentPaymentScripts(psbt);
+ }
+ }
+ }
+
public Wallet getWallet(String walletId) {
return getOpenWallets().entrySet().stream().filter(entry -> entry.getValue().getWalletId(entry.getKey()).equals(walletId)).map(Map.Entry::getKey).findFirst().orElse(null);
}
### src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java
@@ -1363,7 +1363,7 @@ private void signDeviceKeystores() {
try {
PSBT combinedPsbt = headersForm.getPsbt().verifyCombinedSignatures(signedPsbt);
//A device can resolve a silent payment output script, which is only valid if the metadata provided with it proves the claimed address
- verifySilentPaymentScripts(headersForm.getSigningWallet(), combinedPsbt);
+ AppServices.verifySilentPaymentScripts(headersForm.getSigningWallet(), combinedPsbt);
headersForm.getPsbt().combine(signedPsbt);
EventManager.get().post(new PSBTCombinedEvent(headersForm.getPsbt()));
} catch(PSBTSignatureException e) {
@@ -1376,7 +1376,7 @@ private void signDeviceKeystores() {
private boolean verifyPSBT(Wallet signingWallet, PSBT psbt) {
try {
- verifySilentPaymentScripts(signingWallet, psbt);
+ AppServices.verifySilentPaymentScripts(signingWallet, psbt);
} catch(InvalidSilentPaymentException e) {
showErrorDialog("Unverified Silent Payment Outputs", e.getMessage());
return false;
@@ -1385,12 +1385,6 @@ private boolean verifyPSBT(Wallet signingWallet, PSBT psbt) {
return true;
}
- private void verifySilentPaymentScripts(Wallet signingWallet, PSBT psbt) throws InvalidSilentPaymentException {
- if(signingWallet != null) {
- signingWallet.verifySilentPaymentScripts(psbt);
- }
- }
-
private void updateSignedKeystores(Wallet signingWallet) {
Map<?, Map<TransactionSignature, Keystore>> signedKeystoresMap = headersForm.getPsbt() == null ? signingWallet.getSignedKeystores(headersForm.getTransaction()) : signingWallet.getSignedKeystores(headersForm.getPsbt());
Optional<Map<TransactionSignature, Keystore>> optSignedKeystores = signedKeystoresMap.values().stream().filter(map -> !map.isEmpty()).min(Comparator.comparingInt(Map::size));Why this scored 57/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.