File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -541,10 +541,16 @@ public async Task<PSBT> RequestPayjoin(
541541 // Verify that no keypaths is in the PSBT output
542542 if (proposedPSBTOutput.HDKeyPaths.Count != 0)
543543 throw new PayjoinSenderException("The receiver added keypaths to an output");
544- bool isOriginalOutput = originalOutputs.Count > 0 && originalOutputs.Peek().OriginalTxOut.ScriptPubKey == proposedPSBTOutput.ScriptPubKey;
545- if (isOriginalOutput)
544+ if (originalOutputs.Count == 0)
545+ continue;
546+ var originalOutput = originalOutputs.Peek();
547+ bool isOriginalOutput = originalOutput.OriginalTxOut.ScriptPubKey == proposedPSBTOutput.ScriptPubKey;
548+ bool substitutedOutput = !isOriginalOutput &&
549+ allowOutputSubstitution &&
550+ originalOutput.OriginalTxOut.ScriptPubKey == paymentScriptPubKey;
551+ if (isOriginalOutput || substitutedOutput)
546552 {
547- var originalOutput = originalOutputs.Dequeue();
553+ originalOutputs.Dequeue();
548554 if (output.OriginalTxOut == feeOutput)
549555 {
550556 var actualContribution = feeOutput.Value - proposedPSBTOutput.Value;
You can’t perform that action at this time.
0 commit comments