]> git.bitcoin.ninja Git - rust-lightning/commit
Consider commitment tx fee while assembling a route
authorGleb Naumenko <naumenko.gs@gmail.com>
Tue, 7 Mar 2023 08:01:05 +0000 (10:01 +0200)
committerMatt Corallo <git@bluematt.me>
Sun, 21 May 2023 19:05:22 +0000 (19:05 +0000)
commite43cfbd5f16c0c1d0a62a499dd356335e6eef4b9
tree633dc2d012122a199dbb7d99c1a55c6c55c1d30c
parent4b900b7e08b388611501049562d95f6b1dcc0c29
Consider commitment tx fee while 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 include the cost of the commitment transaction fee in our
calculation, subtracting the commitment tx fee cost from the
available as we do in `send_payment`.

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

This commit is based on original work by
Gleb Naumenko <naumenko.gs@gmail.com> and modified by
Matt Corallo <git@bluematt.me>.
lightning/src/ln/channel.rs
lightning/src/ln/functional_tests.rs