mirror of
https://github.com/bitcoin/bips.git
synced 2025-05-12 12:03:29 +00:00
[BIP78] Fix client implementation when there is output substitution
This commit is contained in:
parent
a76f5e4335
commit
d8db3d7608
@ -541,10 +541,16 @@ public async Task<PSBT> RequestPayjoin(
|
|||||||
// Verify that no keypaths is in the PSBT output
|
// Verify that no keypaths is in the PSBT output
|
||||||
if (proposedPSBTOutput.HDKeyPaths.Count != 0)
|
if (proposedPSBTOutput.HDKeyPaths.Count != 0)
|
||||||
throw new PayjoinSenderException("The receiver added keypaths to an output");
|
throw new PayjoinSenderException("The receiver added keypaths to an output");
|
||||||
bool isOriginalOutput = originalOutputs.Count > 0 && originalOutputs.Peek().OriginalTxOut.ScriptPubKey == proposedPSBTOutput.ScriptPubKey;
|
if (originalOutputs.Count == 0)
|
||||||
if (isOriginalOutput)
|
continue;
|
||||||
|
var originalOutput = originalOutputs.Peek();
|
||||||
|
bool isOriginalOutput = originalOutput.OriginalTxOut.ScriptPubKey == proposedPSBTOutput.ScriptPubKey;
|
||||||
|
bool substitutedOutput = !isOriginalOutput &&
|
||||||
|
allowOutputSubstitution &&
|
||||||
|
originalOutput.OriginalTxOut.ScriptPubKey == paymentScriptPubKey;
|
||||||
|
if (isOriginalOutput || substitutedOutput)
|
||||||
{
|
{
|
||||||
var originalOutput = originalOutputs.Dequeue();
|
originalOutputs.Dequeue();
|
||||||
if (output.OriginalTxOut == feeOutput)
|
if (output.OriginalTxOut == feeOutput)
|
||||||
{
|
{
|
||||||
var actualContribution = feeOutput.Value - proposedPSBTOutput.Value;
|
var actualContribution = feeOutput.Value - proposedPSBTOutput.Value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user