@@ -710,7 +710,7 @@ impl ChannelManager {
710
710
}
711
711
712
712
fn get_announcement_sigs ( & self , chan : & Channel ) -> Result < Option < msgs:: AnnouncementSignatures > , HandleError > {
713
- if !chan. is_usable ( ) { return Ok ( None ) }
713
+ if !chan. is_usable ( ) || !chan . should_announce ( ) { return Ok ( None ) }
714
714
715
715
let ( announcement, our_bitcoin_sig) = chan. get_channel_announcement ( self . get_our_node_id ( ) , self . genesis_hash . clone ( ) ) ?;
716
716
let msghash = Message :: from_slice ( & Sha256dHash :: from_data ( & announcement. encode ( ) [ ..] ) [ ..] ) . unwrap ( ) ;
@@ -1839,7 +1839,7 @@ mod tests {
1839
1839
use bitcoin:: util:: misc:: hex_bytes;
1840
1840
use bitcoin:: util:: hash:: Sha256dHash ;
1841
1841
use bitcoin:: util:: uint:: Uint256 ;
1842
- use bitcoin:: blockdata:: block:: BlockHeader ;
1842
+ use bitcoin:: blockdata:: block:: { Block , BlockHeader } ;
1843
1843
use bitcoin:: blockdata:: transaction:: { Transaction , TxOut } ;
1844
1844
use bitcoin:: network:: constants:: Network ;
1845
1845
use bitcoin:: network:: serialize:: serialize;
@@ -2010,6 +2010,7 @@ mod tests {
2010
2010
}
2011
2011
2012
2012
fn confirm_transaction ( chain : & chaininterface:: ChainWatchInterfaceUtil , tx : & Transaction , chan_id : u32 ) {
2013
+ assert ! ( chain. does_match_tx( tx) ) ;
2013
2014
let mut header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
2014
2015
chain. block_connected_checked ( & header, 1 , & [ tx; 1 ] , & [ chan_id; 1 ] ) ;
2015
2016
for i in 2 ..100 {
@@ -2792,9 +2793,9 @@ mod tests {
2792
2793
// Simple case with no pending HTLCs:
2793
2794
nodes[ 1 ] . node . peer_disconnected ( & nodes[ 0 ] . node . get_our_node_id ( ) , true ) ;
2794
2795
{
2795
- let node_txn = test_txn_broadcast ( & nodes[ 1 ] , & chan_1, None , HTLCType :: NONE ) ;
2796
+ let mut node_txn = test_txn_broadcast ( & nodes[ 1 ] , & chan_1, None , HTLCType :: NONE ) ;
2796
2797
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
2797
- nodes[ 0 ] . chain_monitor . block_connected_checked ( & header, 1 , & [ & node_txn[ 0 ] ; 1 ] , & [ 4 ; 1 ] ) ;
2798
+ nodes[ 0 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ node_txn. drain ( .. ) . next ( ) . unwrap ( ) ] } , 1 ) ;
2798
2799
assert_eq ! ( nodes[ 0 ] . tx_broadcaster. txn_broadcasted. lock( ) . unwrap( ) . len( ) , 0 ) ;
2799
2800
}
2800
2801
get_announce_close_broadcast_events ( & nodes, 0 , 1 ) ;
@@ -2807,9 +2808,9 @@ mod tests {
2807
2808
// Simple case of one pending HTLC to HTLC-Timeout
2808
2809
nodes[ 1 ] . node . peer_disconnected ( & nodes[ 2 ] . node . get_our_node_id ( ) , true ) ;
2809
2810
{
2810
- let node_txn = test_txn_broadcast ( & nodes[ 1 ] , & chan_2, None , HTLCType :: TIMEOUT ) ;
2811
+ let mut node_txn = test_txn_broadcast ( & nodes[ 1 ] , & chan_2, None , HTLCType :: TIMEOUT ) ;
2811
2812
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
2812
- nodes[ 2 ] . chain_monitor . block_connected_checked ( & header, 1 , & [ & node_txn[ 0 ] ; 1 ] , & [ 4 ; 1 ] ) ;
2813
+ nodes[ 2 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ node_txn. drain ( .. ) . next ( ) . unwrap ( ) ] } , 1 ) ;
2813
2814
assert_eq ! ( nodes[ 2 ] . tx_broadcaster. txn_broadcasted. lock( ) . unwrap( ) . len( ) , 0 ) ;
2814
2815
}
2815
2816
get_announce_close_broadcast_events ( & nodes, 1 , 2 ) ;
@@ -2848,7 +2849,7 @@ mod tests {
2848
2849
claim_funds ! ( nodes[ 3 ] , nodes[ 2 ] , payment_preimage_1) ;
2849
2850
2850
2851
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
2851
- nodes[ 3 ] . chain_monitor . block_connected_checked ( & header, 1 , & [ & node_txn[ 0 ] ; 1 ] , & [ 4 ; 1 ] ) ;
2852
+ nodes[ 3 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone ( ) ] } , 1 ) ;
2852
2853
2853
2854
check_preimage_claim ( & nodes[ 3 ] , & node_txn) ;
2854
2855
}
@@ -2882,7 +2883,7 @@ mod tests {
2882
2883
test_txn_broadcast ( & nodes[ 4 ] , & chan_4, None , HTLCType :: SUCCESS ) ;
2883
2884
2884
2885
header = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
2885
- nodes[ 4 ] . chain_monitor . block_connected_checked ( & header , TEST_FINAL_CLTV - 5 , & [ & node_txn[ 0 ] ; 1 ] , & [ 4 ; 1 ] ) ;
2886
+ nodes[ 4 ] . chain_monitor . block_connected_with_filtering ( & Block { header , txdata : vec ! [ node_txn[ 0 ] . clone ( ) ] } , TEST_FINAL_CLTV - 5 ) ;
2886
2887
2887
2888
check_preimage_claim ( & nodes[ 4 ] , & node_txn) ;
2888
2889
}
@@ -2902,7 +2903,7 @@ mod tests {
2902
2903
2903
2904
{
2904
2905
let mut header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
2905
- nodes[ 1 ] . chain_monitor . block_connected_checked ( & header, 1 , & vec ! [ & revoked_local_txn[ 0 ] ; 1 ] , & [ 4 ; 1 ] ) ;
2906
+ nodes[ 1 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone ( ) ] } , 1 ) ;
2906
2907
{
2907
2908
let mut node_txn = nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
2908
2909
assert_eq ! ( node_txn. len( ) , 1 ) ;
@@ -2914,10 +2915,10 @@ mod tests {
2914
2915
node_txn. clear ( ) ;
2915
2916
}
2916
2917
2917
- nodes[ 0 ] . chain_monitor . block_connected_checked ( & header, 1 , & vec ! [ & revoked_local_txn[ 0 ] ; 1 ] , & [ 4 ; 0 ] ) ;
2918
+ nodes[ 0 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone ( ) ] } , 1 ) ;
2918
2919
let node_txn = test_txn_broadcast ( & nodes[ 0 ] , & chan_5, Some ( revoked_local_txn[ 0 ] . clone ( ) ) , HTLCType :: TIMEOUT ) ;
2919
2920
header = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
2920
- nodes[ 1 ] . chain_monitor . block_connected_checked ( & header, 1 , & [ & node_txn[ 1 ] ; 1 ] , & [ 4 ; 1 ] ) ;
2921
+ nodes[ 1 ] . chain_monitor . block_connected_with_filtering ( & Block { header, txdata : vec ! [ node_txn[ 1 ] . clone ( ) ] } , 1 ) ;
2921
2922
2922
2923
//TODO: At this point nodes[1] should claim the revoked HTLC-Timeout output, but that's
2923
2924
//not yet implemented in ChannelMonitor
0 commit comments