Skip to content

Commit 7273eb9

Browse files
author
Antoine Riard
committed
Add test-only ChannelMonitor::get_chan_signer to sign spendable output
spending
1 parent c668054 commit 7273eb9

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
@@ -1778,6 +1778,13 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
17781778
Vec::new()
17791779
}
17801780

1781+
/// Get a reference to Channel signer to spend SpendableOutputDescriptor in
1782+
/// test framework
1783+
#[cfg(test)]
1784+
pub fn get_chan_signer(&self) -> &ChanSigner {
1785+
&self.onchain_detection.keys
1786+
}
1787+
17811788
/// Called by SimpleManyChannelMonitor::block_connected, which implements
17821789
/// ChainListener::block_connected.
17831790
/// 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
@@ -273,6 +273,22 @@ macro_rules! get_local_commitment_txn {
273273
}
274274
}
275275

276+
macro_rules! get_chan_signer {
277+
($node: expr, $channel_id: expr) => {
278+
{
279+
let mut monitors = $node.chan_monitor.simple_monitor.monitors.lock().unwrap();
280+
let mut chan_signer = None;
281+
for (funding_txo, monitor) in monitors.iter_mut() {
282+
if funding_txo.to_channel_id() == $channel_id {
283+
chan_signer = Some(monitor.get_chan_signer().clone());
284+
break;
285+
}
286+
}
287+
chan_signer.unwrap()
288+
}
289+
}
290+
}
291+
276292
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) {
277293
let chan_id = *node.network_chan_count.borrow();
278294

0 commit comments

Comments
 (0)