Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
channeld: fix invalid assumption in htlc restore.
A long time ago (93dcd5f), I simplified the htlc reload code so it adjusted the amounts for HTLCs in id order. As we presumably allowed them to be added in that order, this avoided special-casing overflow (which was about to deliberately be made harder by the new amount_msat code). Unfortunately, htlc id order is not canonical, since htlc ids are assigned consecutively in both directions! Concretely, we can have two HTLCs: HTLC #0 LOCAL->REMOTE: 500,000,000 msat, state RCVD_REMOVE_REVOCATION HTLC #0 REMOTE->LOCAL: 10,000 msat, state SENT_ADD_COMMIT On a new remote-funded channel, in which we have 0 balance, these commits *only* work in this order. Sorting by HTLC ID is not enough! In fact, we'd have to worry about redemption order as well, as that matters. So, regretfully, we offset the balances halfway to UINT64_MAX, then check they didn't underflow at the end. This loses us this one sanity check, but that's probably OK. Signed-off-by: Rusty Russell <[email protected]>
- Loading branch information