1

I want to find a dust threshold following this answer: https://bitcoin.stackexchange.com/a/86069/134293

Actually I have a list of transactions coming from listsinceblock in which there are Testnet pubkey hash addresses (like mzzg8fvHXydKs8j9D2a8t7KpSXpGgAnk4n) of 34 bits, and Testnet script hash addresses (like 2N1SP7r92ZZJvYKG2oNtzPwYnzw62up7mTo) of 35 bits -> https://en.bitcoin.it/wiki/List_of_address_prefixes

How can I find the dust threshold for both? Maybe I need just to know how much I have in input in order to apply the formula: ([input bytes]+[34 or 35])*3

1 Answer 1

3

The dust threshold is defined as (output_weight+input_weight)×discard_feerate. The discard_feerate is defined as 3 s/vB. It follows that you need to know the input_weight to calculate an output's dust threshold.

This is easy in the case of P2PKH outputs, because the input has a fixed weight. It is however is impossible in the case of P2SH, P2WSH, and P2TR outputs, because you cannot tell from the address what condition script the recipient encoded in their address to spend the output later. It could be a legacy multisig, wrapped segwit, or some custom construction. In case of P2TR it could be spend per the keypath or the scriptpath which would result in different input weights.

Therefore, the Bitcoin Core code only uses two different dust thresholds: Screenshot of GetDustThreshold(…) via https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp

For all native segwit outputs, it uses the weight of the actual output plus the weight of a P2WPKH input. Note that although

nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);

should evaluate to 67.75 vB, since nSize is a size_t, it actually comes out as 67 vB.

This means for P2WPKH, where an output is 31 vB, the total comes out to 31 vB + 67 vB = 98 vB. This means for P2WPKH dust threshold is 294 satoshis. For P2WSH and P2TR, where outputs are 43 vB, the dust threshold comes out to 330 satoshis.

P2PKH outputs are 34 vB and inputs are 148 vB, so their roundtrip total is 34 vB + 148 vB = 182 vB, and thus the P2PKH dust threshold is 546 satoshis. Since P2SH outputs are only 32 vB for wrapped segwit and all other P2SH outputs, their dust threshold comes out to 540 satoshi.


You can look up address prefixes in this table: https://en.bitcoin.it/wiki/List_of_address_prefixes

  • m… is a testnet P2PKH address
  • 2… is a testnet P2SH address
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.