Include an `outbound_payment` flag in `MaybeTimeoutClaimableHTLC`
When the user is fetching their current balances after forwarding a payment (before it clears), they'll see a
MaybePreimageClaimableHTLC and a MaybeTimeoutClaimableHTLC but if they sum up their balance using
Balance::claimable_amount_satoshis neither will be included.
Obviously, exactly one of the two balances should be included - one of the two resolutions should happen in our favor. This causes our visible balance to fluctuate up and down by the full value of any HTLCs we're in the middle of forwarding, which is incredibly confusing to see. If we want to stop the fluctuations, we need to pick one of the two balances to include. The obvious candidate is MaybeTimeoutClaimableHTLC as it is the lower of the two, and represents our balance without the fee we'd receive from the forward.
Sadly, if we always include it, we'll end up also including any HTLCs which we've sent but which haven't yet been claimed by their recipient, which is the wrong behavior.
Luckily, we have access to the Option<HTLCSource> while walking HTLCs, which allows us to add an outbound_payment flag to MaybeTimeoutClaimableHTLC. This allows us to only include forwarded payments in claimable_amount_satoshis.
Sadly, even with this in place our balance still fluctuates by the changes in the commitment transaction fees we have to pay during forwarding, but addressing that is left for later.
Codecov Report
Attention: 8 lines in your changes are missing coverage. Please review.
Comparison is base (
5d187f6) 88.69% compared to head (c78aa46) 89.01%. Report is 3 commits behind head on main.
:exclamation: Current head c78aa46 differs from pull request most recent head 3bc8048. Consider uploading reports for the commit 3bc8048 to get more accurate results
| Files | Patch % | Lines |
|---|---|---|
| lightning/src/chain/channelmonitor.rs | 66.66% | 7 Missing and 1 partial :warning: |
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## main #2618 +/- ##
==========================================
+ Coverage 88.69% 89.01% +0.31%
==========================================
Files 113 112 -1
Lines 89475 86299 -3176
Branches 89475 86299 -3176
==========================================
- Hits 79359 76817 -2542
+ Misses 7867 7252 -615
+ Partials 2249 2230 -19
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Tagging this as 0.0.117 as we need to do something here, though that could also be reverting #2476.
Okay this really isnt sufficient, I worked on more details but its an increasingly huge patchset. Slipping to 118 and reverting 2476.
Pushed some wip stuff that i think is needed to fully switch over here.
Should also address https://github.com/lightningdevkit/rust-lightning/issues/2738 here.
Hey @TheBlueMatt, could you allow edits by maintainers for this PR so I can take this over? :)
Superseded by #3212.