doc: add dustThreshold explain of P2SH & P2TR #30023

pull jasonandjay wants to merge 2 commits into bitcoin:master from jasonandjay:dustThreshold-P2SH changing 1 files +34 −14
  1. jasonandjay commented at 2:36 PM on May 2, 2024: none

    The calculation of dust in Bitcoin has different values for different payment types. For non-Witness: (148 + vout size)rate For Witness: (67+vout size)rate

    According to our calculation logic, our common P2PKH is 546, P2SH is 540, the minimum value of Witness is P2WPKH is 294, and P2TR is 330

    However, the comments only mentioned P2PKH’s 546 and P2WPKH’s 294, which is inconsistent with the code logic.

    These four payment types are very common in BTC wallets, so I think it is necessary to update the comments

  2. doc: add dustThreshold explain of P2SH 1b5c3be75e
  3. docs: add dustThreshold explain of P2TR 6a14a2d61a
  4. DrahtBot commented at 2:36 PM on May 2, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  5. DrahtBot added the label Docs on May 2, 2024
  6. jasonandjay renamed this:
    doc: add dustThreshold explain of P2SH
    doc: add dustThreshold explain of P2SH & P2TR
    on May 2, 2024
  7. glozow commented at 3:22 PM on May 2, 2024: member

    Thanks for your interest in contributing, but this comment doesn't reflect what the code does (also see #22779 which is linked in a comment in the code). I think this could just be confusing?

  8. bitcoin deleted a comment on May 2, 2024
  9. jasonandjay commented at 3:41 PM on May 2, 2024: none

    Thanks for your interest in contributing, but this comment doesn't reflect what the code does (also see #22779 which is linked in a comment in the code). I think this could just be confusing?

    I checked #22779

    Which part do you think is more confusing?

    I think comments should be consistent with the code

  10. achow101 requested review from glozow on Oct 15, 2024
  11. in src/policy/policy.cpp:50 in 6a14a2d61a
      45 | + *   294 satoshis at the default rate of 3000 sat/kvB.
      46 | + * - A typical spendable segwit P2TR txout is 43 bytes big, and will
      47 | + *   need a CTxIn of at least 57(used 67, see reason below) bytes to spend:
      48 | + *   so dust is a spendable txout less than
      49 | + *   110*dustRelayFee/1000 (in satoshis).
      50 | + *   330 satoshis at the default rate of 3000 sat/kvB.
    


    glozow commented at 3:21 PM on October 15, 2024:

    This specifically does not match the code.


    jasonandjay commented at 3:32 PM on October 15, 2024:

    This specifically does not match the code. Here we want to explain the dust calculation logic of existing common scripts

    The code below simplifies the logic of dust level and says in the comment that the dust limit will not be lowered for segwitv1

    I think we need to explain the situation clearly, although we have some considerations in engineering to choose a general solution


    jasonandjay commented at 3:53 PM on October 15, 2024:

    This explanation will make the entire dust calculation logic more complete and I think it should be considered carefully.


    glozow commented at 4:08 PM on October 15, 2024:

    I somewhat agree that if the code does something slightly different from what one could expect, it may be worth adding a comment - it would depend on the situation. Verbose discussions of engineering tradeoffs usually belong in discussion forums, docs, and bips, not function descriptions.

    What we have currently seems fine to me: "Note this computation is for spending a Segwit v0... For Segwit v1... this computation was kept. See discussion... for more details". It is in a suitable location, i.e. where you might expect to find this code and wonder why it's not there.

    If I were reading the comment added here as a caller, I'd expect that the calculation given here is exactly what the implementation does. Is the p2tr dust threshold is actually 330sat?


    jasonandjay commented at 4:13 PM on October 15, 2024:

    OK, I agree with you. It may be more appropriate to put it in discuss.

    I will close this issue. Thank you for your review.

  12. jasonandjay closed this on Oct 15, 2024

  13. bitcoin locked this on Oct 15, 2025
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me