From 1cc129ed2b8b9027a1123d7cd1f55509c92c9731 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 25 Jun 2024 12:05:51 +0900 Subject: [PATCH] fixup --- bip-0078.mediawiki | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/bip-0078.mediawiki b/bip-0078.mediawiki index 017af75ab1..393cbd1424 100644 --- a/bip-0078.mediawiki +++ b/bip-0078.mediawiki @@ -223,26 +223,7 @@ To prevent this, the sender can agree to pay more fee so the receiver make sure When a sender pick a specific fee rate, the sender expects the transaction to be confirmed after a specific amount of time. But if the receiver adds an input without bumping the fee of the transaction, the payjoin transaction fee rate will be lower, and thus, longer to confirm. -Our recommendation for maxadditionalfeecontribution= is originalPSBTFeeRate * vsize(sender_input_type). - -{| class="wikitable" -!sender_input_type -!vsize(sender_input_type) -|- -|P2WPKH -|68 -|- -|P2PKH -|148 -|- -|P2SH-P2WPKH -|91 -|- -|P2TR -|58 -|} - - +Our recommendation for maxadditionalfeecontribution= is originalPSBTFeeRate * 110. ===Receiver's original PSBT checklist=== @@ -556,7 +537,7 @@ public async Task RequestPayjoin( if (isOriginalOutput || substitutedOutput) { originalOutputs.Dequeue(); - if (output.OriginalTxOut == feeOutput) + if (originalOutput.OriginalTxOut == feeOutput) { var actualContribution = feeOutput.Value - proposedPSBTOutput.Value; // The amount that was subtracted from the output's value is less than or equal to maxadditionalfeecontribution @@ -566,9 +547,10 @@ public async Task RequestPayjoin( if (actualContribution > additionalFee) throw new PayjoinSenderException("The actual contribution is not only paying fee"); // Make sure the actual contribution is only paying for fee incurred by additional inputs + // This assumes an additional input can be up to 110 bytes. int additionalInputsCount = proposalGlobalTx.Inputs.Count - originalGlobalTx.Inputs.Count; - if (additionalInputsCount <= 0) - throw new PayjoinSenderException("Our additional contribution is not paying for additional inputs"); + if (actualContribution > originalFeeRate * 110 * additionalInputsCount) + throw new PayjoinSenderException("The actual contribution is not only paying for additional inputs"); } else if (allowOutputSubstitution && output.OriginalTxOut.ScriptPubKey == paymentScriptPubKey) { @@ -602,21 +584,6 @@ public async Task RequestPayjoin( return proposal; } -int GetVirtualSize(ScriptPubKeyType? scriptPubKeyType) -{ - switch (scriptPubKeyType) - { - case ScriptPubKeyType.Legacy: - return 148; - case ScriptPubKeyType.Segwit: - return 68; - case ScriptPubKeyType.SegwitP2SH: - return 91; - default: - return 110; - } -} - // Finalize the signedPSBT and remove confidential information PSBT CreateOriginalPSBT(PSBT signedPSBT) {