tx_broadcaster: broadcast.clone(),
logger,
default_config: config,
- channel_monitors: &mut monitor_refs,
+ channel_monitors: monitor_refs,
};
(<(BlockHash, ChannelManager<EnforcingChannelKeys, Arc<TestChannelMonitor>, Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>, Arc<dyn Logger>>)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, monitor)
///
/// In such cases the latest local transactions will be sent to the tx_broadcaster included in
/// this struct.
- pub channel_monitors: &'a mut HashMap<OutPoint, &'a mut ChannelMonitor<ChanSigner>>,
+ pub channel_monitors: HashMap<OutPoint, &'a mut ChannelMonitor<ChanSigner>>,
+}
+
+impl<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
+ ChannelManagerReadArgs<'a, ChanSigner, M, T, K, F, L>
+ where M::Target: ManyChannelMonitor<Keys=ChanSigner>,
+ T::Target: BroadcasterInterface,
+ K::Target: KeysInterface<ChanKeySigner = ChanSigner>,
+ F::Target: FeeEstimator,
+ L::Target: Logger,
+ {
+ /// Simple utility function to create a ChannelManagerReadArgs which creates the monitor
+ /// HashMap for you. This is primarily useful for C bindings where it is not practical to
+ /// populate a HashMap directly from C.
+ pub fn new(keys_manager: K, fee_estimator: F, monitor: M, tx_broadcaster: T, logger: L, default_config: UserConfig,
+ mut channel_monitors: Vec<&'a mut ChannelMonitor<ChanSigner>>) -> Self {
+ Self {
+ keys_manager, fee_estimator, monitor, tx_broadcaster, logger, default_config,
+ channel_monitors: channel_monitors.drain(..).map(|monitor| { (monitor.get_funding_txo().0, monitor) }).collect()
+ }
+ }
}
// Implement ReadableArgs for an Arc'd ChannelManager to make it a bit easier to work with the
F::Target: FeeEstimator,
L::Target: Logger,
{
- fn read<R: ::std::io::Read>(reader: &mut R, args: ChannelManagerReadArgs<'a, ChanSigner, M, T, K, F, L>) -> Result<Self, DecodeError> {
+ fn read<R: ::std::io::Read>(reader: &mut R, mut args: ChannelManagerReadArgs<'a, ChanSigner, M, T, K, F, L>) -> Result<Self, DecodeError> {
let _ver: u8 = Readable::read(reader)?;
let min_ver: u8 = Readable::read(reader)?;
if min_ver > SERIALIZATION_VERSION {
monitor: self.chan_monitor,
tx_broadcaster: self.tx_broadcaster.clone(),
logger: &test_utils::TestLogger::new(),
- channel_monitors: &mut channel_monitors,
+ channel_monitors,
}).unwrap();
}
monitor: nodes[0].chan_monitor,
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
logger: &logger,
- channel_monitors: &mut channel_monitors,
+ channel_monitors,
}).unwrap()
};
nodes_0_deserialized = nodes_0_deserialized_tmp;
monitor: nodes[0].chan_monitor,
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
logger: &logger,
- channel_monitors: &mut channel_monitors,
+ channel_monitors,
}).unwrap()
};
nodes_0_deserialized = nodes_0_deserialized_tmp;
monitor: nodes[0].chan_monitor,
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
logger: &logger,
- channel_monitors: &mut channel_monitors,
+ channel_monitors,
}).unwrap()
};
nodes_0_deserialized = nodes_0_deserialized_tmp;
monitor: nodes[0].chan_monitor,
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
logger: &logger,
- channel_monitors: &mut node_0_stale_monitors.iter_mut().map(|monitor| { (monitor.get_funding_txo().0, monitor) }).collect(),
+ channel_monitors: node_0_stale_monitors.iter_mut().map(|monitor| { (monitor.get_funding_txo().0, monitor) }).collect(),
}) { } else {
panic!("If the monitor(s) are stale, this indicates a bug and we should get an Err return");
};
monitor: nodes[0].chan_monitor,
tx_broadcaster: nodes[0].tx_broadcaster.clone(),
logger: &logger,
- channel_monitors: &mut node_0_monitors.iter_mut().map(|monitor| { (monitor.get_funding_txo().0, monitor) }).collect(),
+ channel_monitors: node_0_monitors.iter_mut().map(|monitor| { (monitor.get_funding_txo().0, monitor) }).collect(),
}).unwrap();
nodes_0_deserialized = nodes_0_deserialized_tmp;
assert!(nodes_0_read.is_empty());
logger: &logger,
tx_broadcaster: &tx_broadcaster,
default_config: UserConfig::default(),
- channel_monitors: &mut channel_monitors,
+ channel_monitors,
}).unwrap().1
};
nodes[0].node = &node_state_0;