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)
`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.


No differences found