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 @@ -544,10 +544,16 @@ public async Task<PSBT> RequestPayjoin(
544544 // Verify that no keypaths is in the PSBT output
545545 if (proposedPSBTOutput.HDKeyPaths.Count != 0)
546546 throw new PayjoinSenderException("The receiver added keypaths to an output");
547- bool isOriginalOutput = originalOutputs.Count > 0 && originalOutputs.Peek().OriginalTxOut.ScriptPubKey == proposedPSBTOutput.ScriptPubKey;
548- if (isOriginalOutput)
547+ if (originalOutputs.Count == 0)
548+ continue;
549+ var originalOutput = originalOutputs.Peek();
550+ bool isOriginalOutput = originalOutput.OriginalTxOut.ScriptPubKey == proposedPSBTOutput.ScriptPubKey;
551+ bool substitutedOutput = !isOriginalOutput &&
552+ allowOutputSubstitution &&
553+ originalOutput.OriginalTxOut.ScriptPubKey == paymentScriptPubKey;
554+ if (isOriginalOutput || substitutedOutput)
549555 {
550- var originalOutput = originalOutputs.Dequeue();
556+ originalOutputs.Dequeue();
551557 if (output.OriginalTxOut == feeOutput)
552558 {
553559 var actualContribution = feeOutput.Value - proposedPSBTOutput.Value;
You can’t perform that action at this time.
0 commit comments