-
Notifications
You must be signed in to change notification settings - Fork 268
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
Harden requirements on htlc-minimum-msat #1339
Conversation
We were allowing users to set htlc-minimum-msat to 0, which directly contradicts the fact that we must never send an HTLC for 0 msat. We now explicitly disallow that behavior: the minimum is 1 msat. In case the remote side of a channel had set its htlc-minimum-msat to 0, we would forward HTLC with a value of 0 msat if a sender crafted such a payment. The spec disallows that, so we now explicitly check for that lower bound.
Codecov Report
@@ Coverage Diff @@
## master #1339 +/- ##
==========================================
+ Coverage 77.72% 77.86% +0.13%
==========================================
Files 144 144
Lines 10164 10165 +1
Branches 404 410 +6
==========================================
+ Hits 7900 7915 +15
+ Misses 2264 2250 -14
|
@@ -169,8 +169,8 @@ object Commitments { | |||
return Failure(ExpiryTooBig(commitments.channelId, maximum = maxExpiry, actual = cmd.cltvExpiry, blockCount = blockHeight)) | |||
} | |||
|
|||
if (cmd.amount < commitments.remoteParams.htlcMinimum) { | |||
return Failure(HtlcValueTooSmall(commitments.channelId, minimum = commitments.remoteParams.htlcMinimum, actual = cmd.amount)) | |||
if (cmd.amount < commitments.remoteParams.htlcMinimum.max(1 msat)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this if we have a hard requirement in the settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we can't ensure that our remote has that requirement as well ;)
It seems that c-lightning's default value here is 0, but we still don't want to forward them 0-value HTLCs.
Update fuzzy tests to not use zero-value amounts.
We were allowing users to set htlc-minimum-msat to 0, which directly
contradicts the fact that we must never send an HTLC for 0 msat.
We now explicitly disallow that behavior: the minimum is 1 msat.
In case the remote side of a channel had set its htlc-minimum-msat to 0,
we would forward HTLC with a value of 0 msat if a sender crafted such a
payment. The spec disallows that, so we now explicitly check for that
lower bound.