Consider dust exposure when assembling a route
authorMatt Corallo <git@bluematt.me>
Tue, 16 May 2023 05:00:01 +0000 (05:00 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 6 Jun 2023 23:57:56 +0000 (23:57 +0000)
commit7edbf547fb71f374d1ca11112177d66e8a05852c
tree77bb0502142036e3a7a16dd4c8a8c57ec68b88db
parent3aa8a1721c6968c6a5b40ffc11d3642646b34ceb
Consider dust exposure when assembling a route

When calculating the amount available to send for the next HTLC, if
we over-count we may create routes which are not actually usable.

Historically this has been an issue, which we resolve over a few
commits.

Here we consider how much adding one additional (dust) HTLC would
impact our total dust exposure, setting the new next-HTLC-minimum
field to require HTLCs be non-dust if required or set our next-HTLC
maximum if we cannot send a dust HTLC but do have some additional
exposure remaining.

We also add some testing when sending to ensure that send failures
are accounted for in our balance calculations.

Fixes #2252.
lightning/src/ln/channel.rs
lightning/src/ln/functional_tests.rs