Include inbound-claimed-HTLCs in reported channel balances 2022-01-balance-underflow
authorMatt Corallo <git@bluematt.me>
Thu, 20 Jan 2022 04:28:38 +0000 (04:28 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 10 Feb 2022 22:25:41 +0000 (22:25 +0000)
commit1818c4a115642613faf06ba6cf1ee41b0fba318a
tree1fc424678b779fc87a1a74d54a6cab33a2c7b706
parent35d4ebb208255724804187e3f10553c9383c9522
Include inbound-claimed-HTLCs in reported channel balances

Given the balance is reported as "total balance if we went to chain
ignoring fees", it seems reasonable to include claimed HTLCs - if
we went to chain we'd get those funds, less on-chain fees. Further,
if we do not include them, its possible to have pending outbound
holding-cell HTLCs underflow the balance calculation, causing a
panic in debug mode, and bogus values in release.

This resolves a subtraction underflow bug found by the
`chanmon_consistency` fuzz target.
lightning/src/ln/channel.rs
lightning/src/ln/functional_tests.rs