<p>The dust threshold is defined as <code>(output_weight+input_weight)×discard_feerate</code>. The <code>discard_feerate</code> is defined as 3 s/vB. It follows that you need to know the <code>input_weight</code> to calculate an output's dust threshold.</p>
<p>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 <code>keypath</code> or the <code>scriptpath</code> which would result in different input weights.</p>
<p>Therefore, the Bitcoin Core code only uses two different dust thresholds:
<a href="https://github.com/bitcoin/bitcoin/blob/73b61717a977fc9d23f1bae3f8620641a9dee1f3/src/policy/policy.cpp#L26-L63" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MHPpj.png" alt="Screenshot of GetDustThreshold(…) follow for reading code" /></a> <sup>via <a href="https://github.com/bitcoin/bitcoin/blob/73b61717a977fc9d23f1bae3f8620641a9dee1f3/src/policy/policy.cpp#L26-L63" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp</a></sup></p>
<p>For all native segwit outputs, it uses the weight of the actual output plus the weight of a P2WPKH input. Note that although</p>
<pre><code>nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);
</code></pre>
<p>should evaluate to 67.75 vB, since <code>nSize</code> is a <code>size_t</code>, it actually comes out as 67 vB.</p>
<p>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 <strong>294 satoshis</strong>. For P2WSH and P2TR, where outputs are 43 vB, the dust threshold comes out to <strong>330 satoshis</strong>.</p>
<p>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 <strong>546 satoshis</strong>. Since P2SH outputs are only 32 vB for wrapped segwit and all other P2SH outputs, their dust threshold comes out to <strong>540 satoshi</strong>.</p>
<hr />
<p>You can look up address prefixes in this table:
<a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/List_of_address_prefixes</a></p>
<ul>
<li><code>m…</code> is a testnet P2PKH address</li>
<li><code>2…</code> is a testnet P2SH address</li>
</ul>

CC BY-SA 4.0
2022-05-09T14:39:02.880Z
Thank you! Is clear. But how you find that m is P2PKH and 2 is P2SH address? I did't understood
Giacomo Brunetta
CC BY-SA 4.0
2022-05-09T18:57:20.547Z
@AlfonsoSilvestri See the table linked on https://en.bitcoin.it/wiki/List_of_address_prefixes
Pieter Wuille
CC BY-SA 4.0
2022-05-09T13:58:45.727Z
2022-10-17T19:29:15.740Z
2022-10-17T19:29:15.740Z
Murch
<p>I want to find a dust threshold following this answer: <a href="https://bitcoin.stackexchange.com/a/86069/134293">https://bitcoin.stackexchange.com/a/86069/134293</a></p>
<p>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 -&gt; <a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/List_of_address_prefixes</a></p>
<p>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</p>

<bitcoind><address><testnet><dust><address-format>
Dust threshold for Testnet
Giacomo Brunetta
# Dust threshold for Testnet

(Asked by: username_0 on 2022-05-09)

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

**Tags:** bitcoind, address, testnet, dust, address-format


---

## 1 answers

### Answer by username_1 on 2022-05-09. Score: 4 | Accepted answer

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(…) follow for reading code](https://i.sstatic.net/MHPpj.png)](https://github.com/bitcoin/bitcoin/blob/73b61717a977fc9d23f1bae3f8620641a9dee1f3/src/policy/policy.cpp#L26-L63) via [https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp](https://github.com/bitcoin/bitcoin/blob/73b61717a977fc9d23f1bae3f8620641a9dee1f3/src/policy/policy.cpp#L26-L63)

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

> **Comments:**
> **username_0**: Thank you! Is clear. But how you find that m is P2PKH and 2 is P2SH address? I did't understood  
> **username_2**: @AlfonsoSilvestri See the table linked on https://en.bitcoin.it/wiki/List_of_address_prefixes  

---

