Move channel -> peer tracking to `OutPoint`s from Channel IDs
authorMatt Corallo <git@bluematt.me>
Wed, 29 Nov 2023 21:39:46 +0000 (21:39 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 12 Dec 2023 02:08:36 +0000 (02:08 +0000)
commit9488a1c98d30b8ca9db0197c8dd05f454f69caeb
tree67266f5fb87e700c32d260c29997c3834e562737
parent68e25c6c851b76115613dfd770e27b182404cc56
Move channel -> peer tracking to `OutPoint`s from Channel IDs

For backwards compatibility reasons, we need to track a mapping
from funding outpoints to channel ids. To reduce diff, this was
previously done with channel IDs, converting the `OutPoint`s to
channel IDs before using the map.

This worked fine, but is somewhat brittle - because we allow
redundant channel IDs across different peers, we had to avoid
insertion until we had a real channel ID, and thus also had to be
careful to avoid removal unless we were using a real channel ID,
rather than a temporary one.

This brittleness actually crept in to handling of errors in funding
acceptance, allowing a remote party to get us to remove an entry by
sending a overlapping temporary channel ID with a separate real
channel ID.

Luckily, this map is relatively infrequently used, only used in the
case we see a monitor update completion from a rather ancient
monitor which is unaware of the counterparty node.

Even after this change, the channel -> peer tracking storage is
still somewhat brittle, as we rely on entries not being added until
we are confident no conflicting `OutPoint`s have been used across
channels, and similarly not removing unless that check has
completed.
lightning/src/ln/channelmanager.rs