Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Jun 25, 2024
1 parent ea55024 commit 1cc129e
Showing 1 changed file with 5 additions and 38 deletions.
43 changes: 5 additions & 38 deletions bip-0078.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>maxadditionalfeecontribution=</code> is <code>originalPSBTFeeRate * vsize(sender_input_type)</code>.

{| class="wikitable"
!sender_input_type
!vsize(sender_input_type)
|-
|P2WPKH
|68
|-
|P2PKH
|148
|-
|P2SH-P2WPKH
|91
|-
|P2TR
|58
|}


Our recommendation for <code>maxadditionalfeecontribution=</code> is <code>originalPSBTFeeRate * 110</code>.

This comment has been minimized.

Copy link
@DanGould

DanGould Jul 6, 2024

Where does this fee rate come from? It seems arbitrary. I'm not sure what the problem was with the original suggestion. It makes sense to incentivize input contribution for the sake of privacy but if a different output type is used have the receiver bear the cost.


===Receiver's original PSBT checklist===

Expand Down Expand Up @@ -556,7 +537,7 @@ public async Task<PSBT> 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
Expand All @@ -566,9 +547,10 @@ public async Task<PSBT> 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)
{
Expand Down Expand Up @@ -602,21 +584,6 @@ public async Task<PSBT> 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)
{
Expand Down

0 comments on commit 1cc129e

Please sign in to comment.