Clarify ChannelManager docs somewhat around full blocks 2021-02-791-order-fix
authorMatt Corallo <git@bluematt.me>
Mon, 1 Mar 2021 22:30:41 +0000 (17:30 -0500)
committerMatt Corallo <git@bluematt.me>
Fri, 5 Mar 2021 19:46:29 +0000 (14:46 -0500)
As suggested by Val.

lightning/src/ln/channelmanager.rs
lightning/src/ln/reorg_tests.rs
lightning/src/util/test_utils.rs

index 51920a4f2ebc969d213b531502f7471f09785ff0..86ccc03bab6545b84ad193222671316f459e1cc4 100644 (file)
@@ -4009,8 +4009,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> 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.
index 675602c31888d1f528a9bd3dfb9e5694b26192b3..165f86fc2665627e6bd5c909fdd5d7a6f4c1ce2d 100644 (file)
@@ -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);
index 2d0ad9bf12af3799065637398a136cb4b2648d8a..b96169aadb8023244ba27188e2c955436da8f84b 100644 (file)
@@ -82,9 +82,12 @@ pub struct TestChainMonitor<'a> {
        pub chain_monitor: chainmonitor::ChainMonitor<EnforcingSigner, &'a TestChainSource, &'a chaininterface::BroadcasterInterface, &'a TestFeeEstimator, &'a TestLogger, &'a channelmonitor::Persist<EnforcingSigner>>,
        pub keys_manager: &'a TestKeysInterface,
        pub update_ret: Mutex<Option<Result<(), channelmonitor::ChannelMonitorUpdateErr>>>,
-       // 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<Option<Result<(), channelmonitor::ChannelMonitorUpdateErr>>>,
+       /// 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<Option<([u8; 32], bool)>>,
 }
 impl<'a> TestChainMonitor<'a> {