Function getDustThreshold

  • Given an Output and (optionally) a dust relay fee in satoshis-per-kilobyte, return the minimum satoshi value for this output to not be considered a "dust output". For nodes to relay or mine a transaction with this output, the output must have a satoshi value greater than or equal to this threshold.

    By standardness, if an output is expected to cost more than 1/3 of it's value in fees to spend, it is considered dust. When calculating the expected fee, the input size is assumed to be (at least) the size of a typical P2PKH input spent using a 72-byte ECDSA signature, 148 bytes:

    • Outpoint transaction hash: 32 bytes
    • Outpoint index: 4 bytes
    • Unlocking bytecode length: 1 byte
    • Push of 72-byte ECDSA signature: 72 + 1 byte
    • Push of public key: 33 + 1 byte
    • Sequence number: 4 bytes

    The encoded length of the serialized output is added to 148 bytes, and the dust threshold for the output is 3 times the minimum fee for the total bytes. For a P2PKH output (34 bytes) and the standard 1000 sat/Kb dust relay fee, this results in a dust limit of 546 satoshis ((34+148)*3*1000/1000).

    Note, arbitrary data outputs are not required to meet the dust limit as they are provably unspendable and can be pruned from the UTXO set.


    • output: Output<Uint8Array, Uint8Array>

      the output to test

    • dustRelayFeeSatPerKb: bigint = ...

      the "dust relay fee", defaults to 1000n

    Returns bigint

Generated using TypeDoc