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>
Sat, 16 Apr 2022 20:45:43 +0000 (20:45 +0000)
commit71b68a1df2942e844f41decf21a021dc49b83a40
treef3e6b963e31a528589e76875340032fde994cbc8
parent03f655003d4a70aeb0dc79c4007cba1a7195350a
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.
lightning/src/ln/channel.rs
lightning/src/ln/channelmanager.rs
lightning/src/routing/router.rs