Skip to content

Commit 4fd727f

Browse files
author
Antoine Riard
committed
Add test-only ChannelMonitor::get_chan_signer to sign spendable output
spending
1 parent 5a8f68f commit 4fd727f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,13 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
18221822
Vec::new()
18231823
}
18241824

1825+
/// Get a reference to Channel signer to spend SpendableOutputDescriptor in
1826+
/// test framework
1827+
#[cfg(test)]
1828+
pub fn get_chan_signer(&self) -> &ChanSigner {
1829+
&self.keys
1830+
}
1831+
18251832
/// Called by SimpleManyChannelMonitor::block_connected, which implements
18261833
/// ChainListener::block_connected.
18271834
/// Eventually this should be pub and, roughly, implement ChainListener, however this requires

lightning/src/ln/functional_test_utils.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,22 @@ macro_rules! check_added_monitors {
305305
}
306306
}
307307

308+
macro_rules! get_chan_signer {
309+
($node: expr, $channel_id: expr) => {
310+
{
311+
let mut monitors = $node.chan_monitor.simple_monitor.monitors.lock().unwrap();
312+
let mut chan_signer = None;
313+
for (funding_txo, monitor) in monitors.iter_mut() {
314+
if funding_txo.to_channel_id() == $channel_id {
315+
chan_signer = Some(monitor.get_chan_signer().clone());
316+
break;
317+
}
318+
}
319+
chan_signer.unwrap()
320+
}
321+
}
322+
}
323+
308324
pub fn create_funding_transaction<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, expected_chan_value: u64, expected_user_chan_id: u64) -> ([u8; 32], Transaction, OutPoint) {
309325
let chan_id = *node.network_chan_count.borrow();
310326

0 commit comments

Comments
 (0)