From: Matt Corallo Date: Thu, 19 Mar 2020 01:37:09 +0000 (-0400) Subject: Fetch latest commitment txn via monitor, not channel in test X-Git-Tag: v0.0.12~98^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2020-03-no-chan-mon;p=rust-lightning Fetch latest commitment txn via monitor, not channel in test Eventually, we want to remove the Channel's copy of its own ChannelMonitor, reducing memory footprint and complexity of ChannelManager greatly. This removes the last uses of said ChannelMonitor for latest local commitment transactions (though it is still used for would_broadcast_at_height(), which is the last remaining use). --- diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 746b6228c..2da764b30 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -259,7 +259,17 @@ macro_rules! get_feerate { macro_rules! get_local_commitment_txn { ($node: expr, $channel_id: expr) => { - $node.node.channel_state.lock().unwrap().by_id.get_mut(&$channel_id).unwrap().channel_monitor().get_latest_local_commitment_txn() + { + let mut monitors = $node.chan_monitor.simple_monitor.monitors.lock().unwrap(); + let mut commitment_txn = None; + for (funding_txo, monitor) in monitors.iter_mut() { + if funding_txo.to_channel_id() == $channel_id { + commitment_txn = Some(monitor.get_latest_local_commitment_txn()); + break; + } + } + commitment_txn.unwrap() + } } }