Reload pending payments from ChannelMonitor HTLC data on reload
authorMatt Corallo <git@bluematt.me>
Sun, 10 Oct 2021 23:36:44 +0000 (23:36 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 22 Oct 2021 18:41:42 +0000 (18:41 +0000)
commitfe660c57869f97bcdc4317278b4fe0049ad5b9ff
tree4775a372ec2995a06c98af3cf23b8b237cda57a7
parent0d5050833d99728f0cf4799f7fbb2f2108b1ed93
Reload pending payments from ChannelMonitor HTLC data on reload

If we go to send a payment, add the HTLC(s) to the channel(s),
commit the ChannelMonitor updates to disk, and then crash, we'll
come back up with no pending payments but HTLC(s) ready to be
claim/failed.

This makes it rather impractical to write a payment sender/retryer,
as you cannot guarantee atomicity - you cannot guarantee you'll
have retry data persisted even if the HTLC(s) are actually pending.

Because ChannelMonitors are *the* atomically-persisted data in LDK,
we lean on their current HTLC data to figure out what HTLC(s) are a
part of an outbound payment, rebuilding the pending payments list
on reload.
lightning/src/chain/channelmonitor.rs
lightning/src/ln/channelmanager.rs