Skip to content

Commit 57802e7

Browse files
committed
Remove outpoint_to_peer map in ChannelManager
Now that we require `ChannelMonitor`s to track the channel's counterparty node ID, we can remove the `outpoint_to_peer` map that was used throughout `MonitorEvent` handling. This is a big win for a post-splicing future, as we'll no longer have to bother updating this map when a splice is proposed. Some existing tests providing coverage have been removed as a result.
1 parent 5b71723 commit 57802e7

File tree

4 files changed

+105
-292
lines changed

4 files changed

+105
-292
lines changed

lightning/src/ln/async_signer_tests.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use bitcoin::transaction::Version;
1818

1919
use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
2020
use crate::chain::ChannelMonitorUpdateStatus;
21-
use crate::chain::transaction::OutPoint;
2221
use crate::events::bump_transaction::WalletSource;
2322
use crate::events::{ClosureReason, Event};
2423
use crate::ln::chan_utils::ClosingTransaction;
@@ -1091,9 +1090,4 @@ fn do_test_closing_signed(extra_closing_signed: bool, reconnect: bool) {
10911090
assert!(nodes[1].node.list_channels().is_empty());
10921091
check_closed_event!(nodes[0], 1, ClosureReason::LocallyInitiatedCooperativeClosure, [nodes[1].node.get_our_node_id()], 100000);
10931092
check_closed_event!(nodes[1], 1, ClosureReason::CounterpartyInitiatedCooperativeClosure, [nodes[0].node.get_our_node_id()], 100000);
1094-
1095-
// Check that our maps have been updated after async signing channel closure.
1096-
let funding_outpoint = OutPoint { txid: funding_tx.compute_txid(), index: 0 };
1097-
assert!(nodes[0].node().outpoint_to_peer.lock().unwrap().get(&funding_outpoint).is_none());
1098-
assert!(nodes[1].node().outpoint_to_peer.lock().unwrap().get(&funding_outpoint).is_none());
10991093
}

lightning/src/ln/channel.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3453,6 +3453,24 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
34533453
!matches!(self.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::WAITING_FOR_BATCH))
34543454
}
34553455

3456+
/// Unsets the existing funding information.
3457+
///
3458+
/// This must only be used if the channel has not yet completed funding and has not been used.
3459+
///
3460+
/// Further, the channel must be immediately shut down after this with a call to
3461+
/// [`ChannelContext::force_shutdown`].
3462+
pub fn unset_funding_info(&mut self, funding: &mut FundingScope) {
3463+
debug_assert!(
3464+
matches!(self.channel_state, ChannelState::FundingNegotiated)
3465+
|| matches!(self.channel_state, ChannelState::AwaitingChannelReady(_))
3466+
);
3467+
funding.channel_transaction_parameters.funding_outpoint = None;
3468+
self.channel_id = self.temporary_channel_id.expect(
3469+
"temporary_channel_id should be set since unset_funding_info is only called on funded \
3470+
channels that were unfunded immediately beforehand"
3471+
);
3472+
}
3473+
34563474
/// Transaction nomenclature is somewhat confusing here as there are many different cases - a
34573475
/// transaction is referred to as "a's transaction" implying that a will be able to broadcast
34583476
/// the transaction. Thus, b will generally be sending a signature over such a transaction to
@@ -5165,23 +5183,6 @@ impl<SP: Deref> FundedChannel<SP> where
51655183
self.context.channel_state.clear_waiting_for_batch();
51665184
}
51675185

5168-
/// Unsets the existing funding information.
5169-
///
5170-
/// This must only be used if the channel has not yet completed funding and has not been used.
5171-
///
5172-
/// Further, the channel must be immediately shut down after this with a call to
5173-
/// [`ChannelContext::force_shutdown`].
5174-
pub fn unset_funding_info(&mut self) {
5175-
debug_assert!(matches!(
5176-
self.context.channel_state, ChannelState::AwaitingChannelReady(_)
5177-
));
5178-
self.funding.channel_transaction_parameters.funding_outpoint = None;
5179-
self.context.channel_id = self.context.temporary_channel_id.expect(
5180-
"temporary_channel_id should be set since unset_funding_info is only called on funded \
5181-
channels that were unfunded immediately beforehand"
5182-
);
5183-
}
5184-
51855186
/// Handles a channel_ready message from our peer. If we've already sent our channel_ready
51865187
/// and the channel is now usable (and public), this may generate an announcement_signatures to
51875188
/// reply with.

0 commit comments

Comments
 (0)