Separate `ChannelDetails`' outbound capacity from the next HTLC max
authorMatt Corallo <git@bluematt.me>
Sat, 16 Apr 2022 20:07:34 +0000 (20:07 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 25 Apr 2022 15:04:21 +0000 (15:04 +0000)
commit1af705579ba5b19ffcbd5ee95f8841cf5236e2b9
tree7478d000ccbca085c4d694b49b1eea9d4a333e87
parent637fb88037fa329363e4b6462e9ad01f25cb4e41
Separate `ChannelDetails`' outbound capacity from the next HTLC max

`ChannelDetails::outbound_capacity_msat` describes the total amount
available for sending across several HTLCs, basically just our
balance minus the reserve value maintained by our counterparty.
However, when routing we use it to guess the maximum amount we can
send in a single additional HTLC, which it is not.

There are numerous reasons why our balance may not match the amount
we can send in a single HTLC, whether the HTLC in-flight limit, the
channe's HTLC maximum, or our feerate buffer.

This commit splits the `outbound_capacity_msat` field into two -
`outbound_capacity_msat` and `outbound_htlc_limit_msat`, setting us
up for correctly handling our next-HTLC-limit in the future.

This also addresses the first of the reasons why the values may
not match - the max-in-flight limit. The inaccuracy is ultimately
tracked as #1126.
fuzz/src/router.rs
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/routing/router.rs