From 93a75726a128c5f03e822eb70e65192074eb07b8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 1 Mar 2021 17:30:41 -0500 Subject: [PATCH] Clarify ChannelManager docs somewhat around full blocks As suggested by Val. --- lightning/src/ln/channelmanager.rs | 5 +++-- lightning/src/ln/reorg_tests.rs | 2 ++ lightning/src/util/test_utils.rs | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 51920a4f..86ccc03b 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -4009,8 +4009,9 @@ impl Writeable f /// ChannelManager)>::read(reader, args). /// This may result in closing some Channels if the ChannelMonitor is newer than the stored /// ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted. -/// 3) Register all relevant ChannelMonitor outpoints with your chain watch mechanism using -/// ChannelMonitor::get_outputs_to_watch() and ChannelMonitor::get_funding_txo(). +/// 3) If you are not fetching full blocks, register all relevant ChannelMonitor outpoints the same +/// way you would handle a `chain::Filter` call using ChannelMonitor::get_outputs_to_watch() and +/// ChannelMonitor::get_funding_txo(). /// 4) Reconnect blocks on your ChannelMonitors. /// 5) Disconnect/connect blocks on the ChannelManager. /// 6) Move the ChannelMonitors into your local chain::Watch. diff --git a/lightning/src/ln/reorg_tests.rs b/lightning/src/ln/reorg_tests.rs index 675602c3..165f86fc 100644 --- a/lightning/src/ln/reorg_tests.rs +++ b/lightning/src/ln/reorg_tests.rs @@ -280,6 +280,8 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool) { } } + // With expect_channel_force_closed set the TestChainMonitor will enforce that the next update + // is a ChannelForcClosed on the right channel with should_broadcast set. *nodes[0].chain_monitor.expect_channel_force_closed.lock().unwrap() = Some((chan_id, true)); nodes[0].node.test_process_background_events(); // Required to free the pending background monitor update check_added_monitors!(nodes[0], 1); diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 2d0ad9bf..b96169aa 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -82,9 +82,12 @@ pub struct TestChainMonitor<'a> { pub chain_monitor: chainmonitor::ChainMonitor>, pub keys_manager: &'a TestKeysInterface, pub update_ret: Mutex>>, - // If this is set to Some(), after the next return, we'll always return this until update_ret - // is changed: + /// If this is set to Some(), after the next return, we'll always return this until update_ret + /// is changed: pub next_update_ret: Mutex>>, + /// If this is set to Some(), the next update_channel call (not watch_channel) must be a + /// ChannelForceClosed event for the given channel_id with should_broadcast set to the given + /// boolean. pub expect_channel_force_closed: Mutex>, } impl<'a> TestChainMonitor<'a> { -- 2.30.2