@@ -21,6 +21,7 @@ use ln::features::{InitFeatures, InvoiceFeatures};
21
21
use ln:: msgs;
22
22
use ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
23
23
use util:: enforcing_trait_impls:: EnforcingSigner ;
24
+ use util:: scid_utils;
24
25
use util:: test_utils;
25
26
use util:: test_utils:: { panicking, TestChainMonitor } ;
26
27
use util:: events:: { Event , MessageSendEvent , MessageSendEventsProvider , PaymentPurpose } ;
@@ -48,9 +49,13 @@ pub const CHAN_CONFIRM_DEPTH: u32 = 10;
48
49
49
50
/// Mine the given transaction in the next block and then mine CHAN_CONFIRM_DEPTH - 1 blocks on
50
51
/// top, giving the given transaction CHAN_CONFIRM_DEPTH confirmations.
51
- pub fn confirm_transaction < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , tx : & Transaction ) {
52
- confirm_transaction_at ( node, tx, node. best_block_info ( ) . 1 + 1 ) ;
52
+ ///
53
+ /// Returns the SCID a channel confirmed in the given transaction will have, assuming the funding
54
+ /// output is the 1st output in the transaction.
55
+ pub fn confirm_transaction < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , tx : & Transaction ) -> u64 {
56
+ let scid = confirm_transaction_at ( node, tx, node. best_block_info ( ) . 1 + 1 ) ;
53
57
connect_blocks ( node, CHAN_CONFIRM_DEPTH - 1 ) ;
58
+ scid
54
59
}
55
60
/// Mine a signle block containing the given transaction
56
61
pub fn mine_transaction < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , tx : & Transaction ) {
@@ -59,7 +64,10 @@ pub fn mine_transaction<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &Transac
59
64
}
60
65
/// Mine the given transaction at the given height, mining blocks as required to build to that
61
66
/// height
62
- pub fn confirm_transaction_at < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , tx : & Transaction , conf_height : u32 ) {
67
+ ///
68
+ /// Returns the SCID a channel confirmed in the given transaction will have, assuming the funding
69
+ /// output is the 1st output in the transaction.
70
+ pub fn confirm_transaction_at < ' a , ' b , ' c , ' d > ( node : & ' a Node < ' b , ' c , ' d > , tx : & Transaction , conf_height : u32 ) -> u64 {
63
71
let first_connect_height = node. best_block_info ( ) . 1 + 1 ;
64
72
assert ! ( first_connect_height <= conf_height) ;
65
73
if conf_height > first_connect_height {
@@ -74,6 +82,7 @@ pub fn confirm_transaction_at<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &T
74
82
}
75
83
block. txdata . push ( tx. clone ( ) ) ;
76
84
connect_block ( node, & block) ;
85
+ scid_utils:: scid_from_parts ( conf_height as u64 , block. txdata . len ( ) as u64 - 1 , 0 ) . unwrap ( )
77
86
}
78
87
79
88
/// The possible ways we may notify a ChannelManager of a new block
0 commit comments