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

Harden requirements on htlc-minimum-msat #1339

Merged
merged 2 commits into from
Mar 16, 2020
Merged

Harden requirements on htlc-minimum-msat #1339

merged 2 commits into from
Mar 16, 2020

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Mar 4, 2020

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.

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.
@t-bast t-bast requested a review from pm47 March 4, 2020 09:33
@codecov-io
Copy link

Codecov Report

Merging #1339 into master will increase coverage by 0.13%.
The diff coverage is 100%.

@@            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
Impacted Files Coverage Δ
...re/src/main/scala/fr/acinq/eclair/NodeParams.scala 88.13% <100%> (+0.1%) ⬆️
...in/scala/fr/acinq/eclair/channel/Commitments.scala 90.59% <100%> (ø) ⬆️
...c/main/scala/fr/acinq/eclair/channel/Channel.scala 84.94% <0%> (+0.45%) ⬆️
...src/main/scala/fr/acinq/eclair/router/Router.scala 92.6% <0%> (+0.67%) ⬆️
...q/eclair/blockchain/electrum/ElectrumWatcher.scala 55.2% <0%> (+0.8%) ⬆️
...clair/blockchain/electrum/ElectrumClientPool.scala 82.79% <0%> (+4.3%) ⬆️

@@ -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)) {
Copy link
Member

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?

Copy link
Member Author

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.

@t-bast t-bast merged commit 2df0727 into master Mar 16, 2020
@t-bast t-bast deleted the harden-0-value-htlc branch March 16, 2020 15:51
pm47 added a commit that referenced this pull request Apr 2, 2020
Just less repetition and a better comment.
pm47 added a commit that referenced this pull request Apr 2, 2020
Update fuzzy tests to not use zero-value amounts.
pm47 added a commit that referenced this pull request Apr 2, 2020
Update fuzzy tests to not use zero-value amounts.
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