]> git.bitcoin.ninja Git - rust-lightning/commit
Regenerate PendingHTLCsForwardable on reload instead of serializing 2021-09-forwardable-regen
authorMatt Corallo <git@bluematt.me>
Wed, 15 Sep 2021 19:20:44 +0000 (19:20 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 29 Sep 2021 19:20:38 +0000 (19:20 +0000)
commit0fcc34b9b5a81daea1503a3192cbeba4e38bb020
tree1dfa313cf1357494c3ecfc766d492ac60a34a17b
parent24065c89a9ea4889d3a7c7698ef25d75fa1c172f
Regenerate PendingHTLCsForwardable on reload instead of serializing

When we are prepared to forward HTLCs, we generate a
PendingHTLCsForwardable event with a time in the future when the
user should tell us to forward. This provides some basic batching
of forward events, improving privacy slightly.

After we generate the event, we expect users to spawn a timer in
the background and let us know when it finishes. However, if the
user shuts down before the timer fires, the user will restart and
have no idea that HTLCs are waiting to be forwarded/received.

To fix this, instead of serializing PendingHTLCsForwardable events
to disk while they're pending (before the user starts the timer),
we simply regenerate them when a ChannelManager is deserialized
with HTLCs pending.

Fixes #1042
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_tests.rs
lightning/src/util/events.rs