Skip to content

tapchannel: add a 1msat per HTLC extra tolerance to invoice acceptor #1639

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GeorgeTsagk
Copy link
Member

@GeorgeTsagk GeorgeTsagk commented Jul 4, 2025

Description

When converting an mSAT amount to units and vice versa we frequently get an off-by-1-unit result. This is already accounted for in our invoice acceptor by adding the value of as many asset units as HTLCs in the invoice. What we didn't account for is that the UnitsToMilliSatoshi calculation for the margin can also be off by 1 msat.

So the result of UnitsToMilliSatoshi for the totalUnits - 1 can itself be off by 1mSAT, compared to the result of UnitsToMilliSatoshi for a single unit

When converting an mSAT amount to units and vice versa we frequently get
an off-by-1-unit result. This is already accounted for in our invoice
acceptor by adding the value of as many asset units as HTLCs in the
invoice. What we didn't account for is that the UnitsToMilliSatoshi
calculation for the margin can also be off by 1 msat.
@GeorgeTsagk GeorgeTsagk self-assigned this Jul 4, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 16075827874

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • 46 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.04%) to 39.203%

Files with Coverage Reduction New Missed Lines %
commitment/tap.go 2 72.27%
tapchannel/aux_leaf_signer.go 2 43.08%
tapfreighter/interface.go 4 48.0%
asset/mock.go 11 64.71%
asset/asset.go 27 44.92%
Totals Coverage Status
Change from base Build 16059643780: -0.04%
Covered Lines: 30616
Relevant Lines: 78096

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants