@@ -35,10 +35,9 @@ use std::rc::Rc;
35
35
use std:: sync:: { Arc , Mutex } ;
36
36
use std:: mem;
37
37
use std:: ops:: Deref ;
38
- use std:: marker:: Sized ;
39
38
40
39
pub const CHAN_CONFIRM_DEPTH : u32 = 100 ;
41
- pub fn confirm_transaction ( notifier : & chaininterface:: BlockNotifier , chain : & chaininterface:: ChainWatchInterfaceUtil , tx : & Transaction , chan_id : u32 ) {
40
+ pub fn confirm_transaction < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( notifier : & chaininterface:: BlockNotifier < CL > , chain : & chaininterface:: ChainWatchInterfaceUtil , tx : & Transaction , chan_id : u32 ) {
42
41
assert ! ( chain. does_match_tx( tx) ) ;
43
42
let mut header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
44
43
notifier. block_connected_checked ( & header, 1 , & [ tx; 1 ] , & [ chan_id; 1 ] ) ;
@@ -48,7 +47,7 @@ pub fn confirm_transaction(notifier: &chaininterface::BlockNotifier, chain: &cha
48
47
}
49
48
}
50
49
51
- pub fn connect_blocks ( notifier : & chaininterface:: BlockNotifier , depth : u32 , height : u32 , parent : bool , prev_blockhash : Sha256d ) -> Sha256d {
50
+ pub fn connect_blocks < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( notifier : & chaininterface:: BlockNotifier < CL > , depth : u32 , height : u32 , parent : bool , prev_blockhash : Sha256d ) -> Sha256d {
52
51
let mut header = BlockHeader { version : 0x2000000 , prev_blockhash : if parent { prev_blockhash } else { Default :: default ( ) } , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
53
52
notifier. block_connected_checked ( & header, height + 1 , & Vec :: new ( ) , & Vec :: new ( ) ) ;
54
53
for i in 2 ..depth + 1 {
@@ -71,7 +70,8 @@ pub struct Node {
71
70
pub network_chan_count : Rc < RefCell < u32 > > ,
72
71
pub logger : Arc < test_utils:: TestLogger >
73
72
}
74
- impl Drop for Node {
73
+
74
+ impl < CL : Deref < Target = chaininterface:: ChainListener > + Clone > Drop for Node < CL > {
75
75
fn drop ( & mut self ) {
76
76
if !:: std:: thread:: panicking ( ) {
77
77
// Check that we processed all pending events
@@ -82,11 +82,11 @@ impl Drop for Node {
82
82
}
83
83
}
84
84
85
- pub fn create_chan_between_nodes ( node_a : & Node , node_b : & Node , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
85
+ pub fn create_chan_between_nodes < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_a : & Node < CL > , node_b : & Node < CL > , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
86
86
create_chan_between_nodes_with_value ( node_a, node_b, 100000 , 10001 , a_flags, b_flags)
87
87
}
88
88
89
- pub fn create_chan_between_nodes_with_value ( node_a : & Node , node_b : & Node , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
89
+ pub fn create_chan_between_nodes_with_value < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_a : & Node < CL > , node_b : & Node < CL > , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
90
90
let ( funding_locked, channel_id, tx) = create_chan_between_nodes_with_value_a ( node_a, node_b, channel_value, push_msat, a_flags, b_flags) ;
91
91
let ( announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b ( node_a, node_b, & funding_locked) ;
92
92
( announcement, as_update, bs_update, channel_id, tx)
@@ -161,7 +161,7 @@ macro_rules! get_feerate {
161
161
}
162
162
}
163
163
164
- pub fn create_funding_transaction ( node : & Node , expected_chan_value : u64 , expected_user_chan_id : u64 ) -> ( [ u8 ; 32 ] , Transaction , OutPoint ) {
164
+ pub fn create_funding_transaction < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node : & Node < CL > , expected_chan_value : u64 , expected_user_chan_id : u64 ) -> ( [ u8 ; 32 ] , Transaction , OutPoint ) {
165
165
let chan_id = * node. network_chan_count . borrow ( ) ;
166
166
167
167
let events = node. node . get_and_clear_pending_events ( ) ;
@@ -181,7 +181,7 @@ pub fn create_funding_transaction(node: &Node, expected_chan_value: u64, expecte
181
181
}
182
182
}
183
183
184
- pub fn create_chan_between_nodes_with_value_init ( node_a : & Node , node_b : & Node , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> Transaction {
184
+ pub fn create_chan_between_nodes_with_value_init < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_a : & Node < CL > , node_b : & Node < CL > , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> Transaction {
185
185
node_a. node . create_channel ( node_b. node . get_our_node_id ( ) , channel_value, push_msat, 42 ) . unwrap ( ) ;
186
186
node_b. node . handle_open_channel ( & node_a. node . get_our_node_id ( ) , a_flags, & get_event_msg ! ( node_a, MessageSendEvent :: SendOpenChannel , node_b. node. get_our_node_id( ) ) ) ;
187
187
node_a. node . handle_accept_channel ( & node_b. node . get_our_node_id ( ) , b_flags, & get_event_msg ! ( node_b, MessageSendEvent :: SendAcceptChannel , node_a. node. get_our_node_id( ) ) ) ;
@@ -225,12 +225,12 @@ pub fn create_chan_between_nodes_with_value_init(node_a: &Node, node_b: &Node, c
225
225
tx
226
226
}
227
227
228
- pub fn create_chan_between_nodes_with_value_confirm_first ( node_recv : & Node , node_conf : & Node , tx : & Transaction ) {
228
+ pub fn create_chan_between_nodes_with_value_confirm_first < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_recv : & Node < CL > , node_conf : & Node < CL > , tx : & Transaction ) {
229
229
confirm_transaction ( & node_conf. block_notifier , & node_conf. chain_monitor , & tx, tx. version ) ;
230
230
node_recv. node . handle_funding_locked ( & node_conf. node . get_our_node_id ( ) , & get_event_msg ! ( node_conf, MessageSendEvent :: SendFundingLocked , node_recv. node. get_our_node_id( ) ) ) ;
231
231
}
232
232
233
- pub fn create_chan_between_nodes_with_value_confirm_second ( node_recv : & Node , node_conf : & Node ) -> ( ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) , [ u8 ; 32 ] ) {
233
+ pub fn create_chan_between_nodes_with_value_confirm_second < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_recv : & Node < CL > , node_conf : & Node < CL > ) -> ( ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) , [ u8 ; 32 ] ) {
234
234
let channel_id;
235
235
let events_6 = node_conf. node . get_and_clear_pending_msg_events ( ) ;
236
236
assert_eq ! ( events_6. len( ) , 2 ) ;
@@ -250,19 +250,19 @@ pub fn create_chan_between_nodes_with_value_confirm_second(node_recv: &Node, nod
250
250
} ) , channel_id)
251
251
}
252
252
253
- pub fn create_chan_between_nodes_with_value_confirm ( node_a : & Node , node_b : & Node , tx : & Transaction ) -> ( ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) , [ u8 ; 32 ] ) {
253
+ pub fn create_chan_between_nodes_with_value_confirm < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_a : & Node < CL > , node_b : & Node < CL > , tx : & Transaction ) -> ( ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) , [ u8 ; 32 ] ) {
254
254
create_chan_between_nodes_with_value_confirm_first ( node_a, node_b, tx) ;
255
255
confirm_transaction ( & node_a. block_notifier , & node_a. chain_monitor , & tx, tx. version ) ;
256
256
create_chan_between_nodes_with_value_confirm_second ( node_b, node_a)
257
257
}
258
258
259
- pub fn create_chan_between_nodes_with_value_a ( node_a : & Node , node_b : & Node , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) , [ u8 ; 32 ] , Transaction ) {
259
+ pub fn create_chan_between_nodes_with_value_a < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_a : & Node < CL > , node_b : & Node < CL > , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) , [ u8 ; 32 ] , Transaction ) {
260
260
let tx = create_chan_between_nodes_with_value_init ( node_a, node_b, channel_value, push_msat, a_flags, b_flags) ;
261
261
let ( msgs, chan_id) = create_chan_between_nodes_with_value_confirm ( node_a, node_b, & tx) ;
262
262
( msgs, chan_id, tx)
263
263
}
264
264
265
- pub fn create_chan_between_nodes_with_value_b ( node_a : & Node , node_b : & Node , as_funding_msgs : & ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate ) {
265
+ pub fn create_chan_between_nodes_with_value_b < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_a : & Node < CL > , node_b : & Node < CL > , as_funding_msgs : & ( msgs:: FundingLocked , msgs:: AnnouncementSignatures ) ) -> ( msgs:: ChannelAnnouncement , msgs:: ChannelUpdate , msgs:: ChannelUpdate ) {
266
266
node_b. node . handle_funding_locked ( & node_a. node . get_our_node_id ( ) , & as_funding_msgs. 0 ) ;
267
267
let bs_announcement_sigs = get_event_msg ! ( node_b, MessageSendEvent :: SendAnnouncementSignatures , node_a. node. get_our_node_id( ) ) ;
268
268
node_b. node . handle_announcement_signatures ( & node_a. node . get_our_node_id ( ) , & as_funding_msgs. 1 ) ;
@@ -294,11 +294,11 @@ pub fn create_chan_between_nodes_with_value_b(node_a: &Node, node_b: &Node, as_f
294
294
( ( * announcement) . clone ( ) , ( * as_update) . clone ( ) , ( * bs_update) . clone ( ) )
295
295
}
296
296
297
- pub fn create_announced_chan_between_nodes ( nodes : & Vec < Node > , a : usize , b : usize , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
297
+ pub fn create_announced_chan_between_nodes < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( nodes : & Vec < Node < CL > > , a : usize , b : usize , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
298
298
create_announced_chan_between_nodes_with_value ( nodes, a, b, 100000 , 10001 , a_flags, b_flags)
299
299
}
300
300
301
- pub fn create_announced_chan_between_nodes_with_value ( nodes : & Vec < Node > , a : usize , b : usize , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
301
+ pub fn create_announced_chan_between_nodes_with_value < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( nodes : & Vec < Node < CL > > , a : usize , b : usize , channel_value : u64 , push_msat : u64 , a_flags : LocalFeatures , b_flags : LocalFeatures ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) {
302
302
let chan_announcement = create_chan_between_nodes_with_value ( & nodes[ a] , & nodes[ b] , channel_value, push_msat, a_flags, b_flags) ;
303
303
for node in nodes {
304
304
assert ! ( node. router. handle_channel_announcement( & chan_announcement. 0 ) . unwrap( ) ) ;
@@ -368,7 +368,7 @@ macro_rules! check_closed_broadcast {
368
368
} }
369
369
}
370
370
371
- pub fn close_channel ( outbound_node : & Node , inbound_node : & Node , channel_id : & [ u8 ; 32 ] , funding_tx : Transaction , close_inbound_first : bool ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , Transaction ) {
371
+ pub fn close_channel < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( outbound_node : & Node < CL > , inbound_node : & Node < CL > , channel_id : & [ u8 ; 32 ] , funding_tx : Transaction , close_inbound_first : bool ) -> ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , Transaction ) {
372
372
let ( node_a, broadcaster_a, struct_a) = if close_inbound_first { ( & inbound_node. node , & inbound_node. tx_broadcaster , inbound_node) } else { ( & outbound_node. node , & outbound_node. tx_broadcaster , outbound_node) } ;
373
373
let ( node_b, broadcaster_b) = if close_inbound_first { ( & outbound_node. node , & outbound_node. tx_broadcaster ) } else { ( & inbound_node. node , & inbound_node. tx_broadcaster ) } ;
374
374
let ( tx_a, tx_b) ;
@@ -455,7 +455,7 @@ impl SendEvent {
455
455
}
456
456
}
457
457
458
- pub fn from_node ( node : & Node ) -> SendEvent {
458
+ pub fn from_node < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node : & Node < CL > ) -> SendEvent {
459
459
let mut events = node. node . get_and_clear_pending_msg_events ( ) ;
460
460
assert_eq ! ( events. len( ) , 1 ) ;
461
461
SendEvent :: from_event ( events. pop ( ) . unwrap ( ) )
@@ -603,7 +603,7 @@ macro_rules! expect_payment_sent {
603
603
}
604
604
}
605
605
606
- pub fn send_along_route_with_hash ( origin_node : & Node , route : Route , expected_route : & [ & Node ] , recv_value : u64 , our_payment_hash : PaymentHash ) {
606
+ pub fn send_along_route_with_hash < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , route : Route , expected_route : & [ & Node < CL > ] , recv_value : u64 , our_payment_hash : PaymentHash ) {
607
607
let mut payment_event = {
608
608
origin_node. node . send_payment ( route, our_payment_hash) . unwrap ( ) ;
609
609
check_added_monitors ! ( origin_node, 1 ) ;
@@ -645,13 +645,13 @@ pub fn send_along_route_with_hash(origin_node: &Node, route: Route, expected_rou
645
645
}
646
646
}
647
647
648
- pub fn send_along_route ( origin_node : & Node , route : Route , expected_route : & [ & Node ] , recv_value : u64 ) -> ( PaymentPreimage , PaymentHash ) {
648
+ pub fn send_along_route < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , route : Route , expected_route : & [ & Node < CL > ] , recv_value : u64 ) -> ( PaymentPreimage , PaymentHash ) {
649
649
let ( our_payment_preimage, our_payment_hash) = get_payment_preimage_hash ! ( origin_node) ;
650
650
send_along_route_with_hash ( origin_node, route, expected_route, recv_value, our_payment_hash) ;
651
651
( our_payment_preimage, our_payment_hash)
652
652
}
653
653
654
- pub fn claim_payment_along_route ( origin_node : & Node , expected_route : & [ & Node ] , skip_last : bool , our_payment_preimage : PaymentPreimage , expected_amount : u64 ) {
654
+ pub fn claim_payment_along_route < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , expected_route : & [ & Node < CL > ] , skip_last : bool , our_payment_preimage : PaymentPreimage , expected_amount : u64 ) {
655
655
assert ! ( expected_route. last( ) . unwrap( ) . node. claim_funds( our_payment_preimage, expected_amount) ) ;
656
656
check_added_monitors ! ( expected_route. last( ) . unwrap( ) , 1 ) ;
657
657
@@ -729,13 +729,13 @@ pub fn claim_payment_along_route(origin_node: &Node, expected_route: &[&Node], s
729
729
}
730
730
}
731
731
732
- pub fn claim_payment ( origin_node : & Node , expected_route : & [ & Node ] , our_payment_preimage : PaymentPreimage , expected_amount : u64 ) {
732
+ pub fn claim_payment < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , expected_route : & [ & Node < CL > ] , our_payment_preimage : PaymentPreimage , expected_amount : u64 ) {
733
733
claim_payment_along_route ( origin_node, expected_route, false , our_payment_preimage, expected_amount) ;
734
734
}
735
735
736
736
pub const TEST_FINAL_CLTV : u32 = 32 ;
737
737
738
- pub fn route_payment ( origin_node : & Node , expected_route : & [ & Node ] , recv_value : u64 ) -> ( PaymentPreimage , PaymentHash ) {
738
+ pub fn route_payment < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , expected_route : & [ & Node < CL > ] , recv_value : u64 ) -> ( PaymentPreimage , PaymentHash ) {
739
739
let route = origin_node. router . get_route ( & expected_route. last ( ) . unwrap ( ) . node . get_our_node_id ( ) , None , & Vec :: new ( ) , recv_value, TEST_FINAL_CLTV ) . unwrap ( ) ;
740
740
assert_eq ! ( route. hops. len( ) , expected_route. len( ) ) ;
741
741
for ( node, hop) in expected_route. iter ( ) . zip ( route. hops . iter ( ) ) {
@@ -745,7 +745,7 @@ pub fn route_payment(origin_node: &Node, expected_route: &[&Node], recv_value: u
745
745
send_along_route ( origin_node, route, expected_route, recv_value)
746
746
}
747
747
748
- pub fn route_over_limit ( origin_node : & Node , expected_route : & [ & Node ] , recv_value : u64 ) {
748
+ pub fn route_over_limit < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , expected_route : & [ & Node < CL > ] , recv_value : u64 ) {
749
749
let route = origin_node. router . get_route ( & expected_route. last ( ) . unwrap ( ) . node . get_our_node_id ( ) , None , & Vec :: new ( ) , recv_value, TEST_FINAL_CLTV ) . unwrap ( ) ;
750
750
assert_eq ! ( route. hops. len( ) , expected_route. len( ) ) ;
751
751
for ( node, hop) in expected_route. iter ( ) . zip ( route. hops . iter ( ) ) {
@@ -761,12 +761,12 @@ pub fn route_over_limit(origin_node: &Node, expected_route: &[&Node], recv_value
761
761
} ;
762
762
}
763
763
764
- pub fn send_payment ( origin : & Node , expected_route : & [ & Node ] , recv_value : u64 , expected_value : u64 ) {
764
+ pub fn send_payment < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin : & Node < CL > , expected_route : & [ & Node < CL > ] , recv_value : u64 , expected_value : u64 ) {
765
765
let our_payment_preimage = route_payment ( & origin, expected_route, recv_value) . 0 ;
766
766
claim_payment ( & origin, expected_route, our_payment_preimage, expected_value) ;
767
767
}
768
768
769
- pub fn fail_payment_along_route ( origin_node : & Node , expected_route : & [ & Node ] , skip_last : bool , our_payment_hash : PaymentHash ) {
769
+ pub fn fail_payment_along_route < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , expected_route : & [ & Node < CL > ] , skip_last : bool , our_payment_hash : PaymentHash ) {
770
770
assert ! ( expected_route. last( ) . unwrap( ) . node. fail_htlc_backwards( & our_payment_hash) ) ;
771
771
expect_pending_htlcs_forwardable ! ( expected_route. last( ) . unwrap( ) ) ;
772
772
check_added_monitors ! ( expected_route. last( ) . unwrap( ) , 1 ) ;
@@ -835,11 +835,11 @@ pub fn fail_payment_along_route(origin_node: &Node, expected_route: &[&Node], sk
835
835
}
836
836
}
837
837
838
- pub fn fail_payment ( origin_node : & Node , expected_route : & [ & Node ] , our_payment_hash : PaymentHash ) {
838
+ pub fn fail_payment < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( origin_node : & Node < CL > , expected_route : & [ & Node < CL > ] , our_payment_hash : PaymentHash ) {
839
839
fail_payment_along_route ( origin_node, expected_route, false , our_payment_hash) ;
840
840
}
841
841
842
- pub fn create_network ( node_count : usize , node_config : & [ Option < UserConfig > ] ) -> Vec < Node > {
842
+ pub fn create_network < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_count : usize , node_config : & [ Option < UserConfig > ] ) -> Vec < Node < CL > > {
843
843
let mut nodes = Vec :: new ( ) ;
844
844
let mut rng = thread_rng ( ) ;
845
845
let secp_ctx = Secp256k1 :: new ( ) ;
@@ -891,7 +891,7 @@ pub enum HTLCType { NONE, TIMEOUT, SUCCESS }
891
891
///
892
892
/// All broadcast transactions must be accounted for in one of the above three types of we'll
893
893
/// also fail.
894
- pub fn test_txn_broadcast ( node : & Node , chan : & ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) , commitment_tx : Option < Transaction > , has_htlc_tx : HTLCType ) -> Vec < Transaction > {
894
+ pub fn test_txn_broadcast < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node : & Node < CL > , chan : & ( msgs:: ChannelUpdate , msgs:: ChannelUpdate , [ u8 ; 32 ] , Transaction ) , commitment_tx : Option < Transaction > , has_htlc_tx : HTLCType ) -> Vec < Transaction > {
895
895
let mut node_txn = node. tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
896
896
assert ! ( node_txn. len( ) >= if commitment_tx. is_some( ) { 0 } else { 1 } + if has_htlc_tx == HTLCType :: NONE { 0 } else { 1 } ) ;
897
897
@@ -936,7 +936,7 @@ pub fn test_txn_broadcast(node: &Node, chan: &(msgs::ChannelUpdate, msgs::Channe
936
936
937
937
/// Tests that the given node has broadcast a claim transaction against the provided revoked
938
938
/// HTLC transaction.
939
- pub fn test_revoked_htlc_claim_txn_broadcast ( node : & Node , revoked_tx : Transaction , commitment_revoked_tx : Transaction ) {
939
+ pub fn test_revoked_htlc_claim_txn_broadcast < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node : & Node < CL > , revoked_tx : Transaction , commitment_revoked_tx : Transaction ) {
940
940
let mut node_txn = node. tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
941
941
// We should issue a 2nd transaction if one htlc is dropped from initial claiming tx
942
942
// but sometimes not as feerate is too-low
@@ -954,7 +954,7 @@ pub fn test_revoked_htlc_claim_txn_broadcast(node: &Node, revoked_tx: Transactio
954
954
assert ! ( node_txn. is_empty( ) ) ;
955
955
}
956
956
957
- pub fn check_preimage_claim ( node : & Node , prev_txn : & Vec < Transaction > ) -> Vec < Transaction > {
957
+ pub fn check_preimage_claim < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node : & Node < CL > , prev_txn : & Vec < Transaction > ) -> Vec < Transaction > {
958
958
let mut node_txn = node. tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
959
959
960
960
assert ! ( node_txn. len( ) >= 1 ) ;
@@ -978,7 +978,7 @@ pub fn check_preimage_claim(node: &Node, prev_txn: &Vec<Transaction>) -> Vec<Tra
978
978
res
979
979
}
980
980
981
- pub fn get_announce_close_broadcast_events ( nodes : & Vec < Node > , a : usize , b : usize ) {
981
+ pub fn get_announce_close_broadcast_events < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( nodes : & Vec < Node < CL > > , a : usize , b : usize ) {
982
982
let events_1 = nodes[ a] . node . get_and_clear_pending_msg_events ( ) ;
983
983
assert_eq ! ( events_1. len( ) , 1 ) ;
984
984
let as_update = match events_1[ 0 ] {
@@ -1085,7 +1085,7 @@ macro_rules! handle_chan_reestablish_msgs {
1085
1085
1086
1086
/// pending_htlc_adds includes both the holding cell and in-flight update_add_htlcs, whereas
1087
1087
/// for claims/fails they are separated out.
1088
- pub fn reconnect_nodes ( node_a : & Node , node_b : & Node , send_funding_locked : ( bool , bool ) , pending_htlc_adds : ( i64 , i64 ) , pending_htlc_claims : ( usize , usize ) , pending_cell_htlc_claims : ( usize , usize ) , pending_cell_htlc_fails : ( usize , usize ) , pending_raa : ( bool , bool ) ) {
1088
+ pub fn reconnect_nodes < CL : Deref < Target = chaininterface :: ChainListener > + Clone > ( node_a : & Node < CL > , node_b : & Node < CL > , send_funding_locked : ( bool , bool ) , pending_htlc_adds : ( i64 , i64 ) , pending_htlc_claims : ( usize , usize ) , pending_cell_htlc_claims : ( usize , usize ) , pending_cell_htlc_fails : ( usize , usize ) , pending_raa : ( bool , bool ) ) {
1089
1089
node_a. node . peer_connected ( & node_b. node . get_our_node_id ( ) ) ;
1090
1090
let reestablish_1 = get_chan_reestablish_msgs ! ( node_a, node_b) ;
1091
1091
node_b. node . peer_connected ( & node_a. node . get_our_node_id ( ) ) ;
0 commit comments