Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mempool: introduce GetDustThreshold to export dust limit calculation #1742

Merged

Conversation

Crypt-iQ
Copy link
Collaborator

@Crypt-iQ Crypt-iQ commented Aug 16, 2021

This commit modifies no behavior and would allow other projects to retrieve the dust limit for a particular output type before the amount of the output is known (so IsDust wouldn't be possible). This is particularly useful in the Lightning Network for channel negotiation. I did not include a unit test but I did locally check the following dust limits at the current 3000sat/kvb dust relay feerate:

  • p2pkh: 546
  • p2sh: 540
  • p2wsh: 330
  • p2wpkh: 294
  • p2tr: 330

This commit modifies no behavior and would allow other projects to
retrieve the dust limit for a particular output type before the
amount of the output is known. This is particularly useful in the
Lightning Network for channel negotiation.
@coveralls
Copy link

coveralls commented Aug 16, 2021

Pull Request Test Coverage Report for Build 1136251577

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.06%) to 52.959%

Files with Coverage Reduction New Missed Lines %
peer/peer.go 3 75.63%
Totals Coverage Status
Change from base Build 1094114370: 0.06%
Covered Lines: 21076
Relevant Lines: 39797

💛 - Coveralls

@jcvernaleo
Copy link
Member

I just forced github to rerun the failing tests in case it was just a fluke. If the tests fail again, could you take a look at them before we review?

@Crypt-iQ
Copy link
Collaborator Author

@jcvernaleo the tests pass locally on my machine, looking at the CI the failures seem unrelated

@onyb onyb self-requested a review August 18, 2021 17:26
@onyb onyb added the mempool label Aug 18, 2021
@@ -253,6 +246,20 @@ func IsDust(txOut *wire.TxOut, minRelayTxFee btcutil.Amount) bool {
totalSize += 107
}

return 3 * int64(totalSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the factor of 3 here retained? When in the original dust calculation, this value is used to ensure that the amount spent on fees to spend an output isn't greater than 1/3 of the relay fee.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, we chatted offline and derived why this is in place.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ⛳️

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@jcvernaleo jcvernaleo merged commit f8e6854 into btcsuite:master Sep 16, 2021
@Crypt-iQ Crypt-iQ deleted the mempool_dust_threshold_08162021 branch September 16, 2021 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants