Open dongcarl opened 1 year ago
We had a quick call and we found a potential explanation for the inconsistency: while the HTLC is still pending we may still consider the HTLC's value to be on the sender side, while the recipient also considers it as theirs. The more correct model would be to have three buckets: ours, theirs, and undecided.
IIRC we are glossing over the last category in order to prevent situations where neither node would consider it as theirs (stuck HTLC?) thus causing a perceived loss of funds and any monitoring having frequent dips when summing up just ours + theirs.
It would be interesting to see if this intuition is true by either waiting for the HTLC removal to be committed before listfunds
(which should not present this behavior) and checking that the HTLC is still present in the listpeers
output when the behavior manifests.
There are a number of solutions here:
update_fulfill_htlc
and update_fail_htlc
as the switch-over point from sender to recipient (may flipflop if we happen to lose connection between HTLC removal and commitment since the HTLC will be re-played upon connecting)
See below for a minimal reproducer.
If I spin up 2 nodes (
l1
,l2
) with a 75k sats channel froml1
tol2
, then make a payment of 50k sats froml1
tol2
. I expect:l1
'slistfunds
to show that "our_amount_msat" to be 25k satsl1
's "our_amount_msat" was the full 75k sats like the payment had never been madel2
'slistfunds
to show that "our_amount_msat" to be 50k satsl1
'sgetroute
for 50k sats tol2
to fail (since there are not enough sats)getroute
returned the same channel, that wouldn't be able to route the 50k satsI could be using things wrong, but this was quite surprising to me.