@@ -4012,6 +4012,8 @@ fn test_claim_sizeable_push_msat() {
4012
4012
4013
4013
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4014
4014
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
4015
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4016
+
4015
4017
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4016
4018
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4017
4019
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
@@ -4038,6 +4040,8 @@ fn test_claim_on_remote_sizeable_push_msat() {
4038
4040
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4039
4041
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
4040
4042
check_closed_broadcast ! ( nodes[ 1 ] , false ) ;
4043
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4044
+
4041
4045
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4042
4046
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4043
4047
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
@@ -4068,6 +4072,7 @@ fn test_claim_on_remote_revoked_sizeable_push_msat() {
4068
4072
let node_txn = nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
4069
4073
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4070
4074
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4075
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4071
4076
4072
4077
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4073
4078
assert_eq ! ( spend_txn. len( ) , 3 ) ;
@@ -4117,6 +4122,7 @@ fn test_static_spendable_outputs_preimage_tx() {
4117
4122
4118
4123
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4119
4124
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4125
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4120
4126
4121
4127
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4122
4128
assert_eq ! ( spend_txn. len( ) , 1 ) ;
@@ -4151,6 +4157,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() {
4151
4157
4152
4158
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4153
4159
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4160
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4154
4161
4155
4162
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4156
4163
assert_eq ! ( spend_txn. len( ) , 1 ) ;
@@ -4203,6 +4210,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
4203
4210
4204
4211
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4205
4212
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) , node_txn[ 2 ] . clone( ) ] } , 1 ) ;
4213
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4206
4214
4207
4215
// Check B's ChannelMonitor was able to generate the right spendable output descriptor
4208
4216
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
@@ -4251,6 +4259,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() {
4251
4259
4252
4260
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4253
4261
nodes[ 0 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) , node_txn[ 2 ] . clone( ) ] } , 1 ) ;
4262
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4254
4263
4255
4264
// Check A's ChannelMonitor was able to generate the right spendable output descriptor
4256
4265
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
@@ -4522,6 +4531,7 @@ fn test_dynamic_spendable_outputs_local_htlc_success_tx() {
4522
4531
4523
4532
let header_201 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4524
4533
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_201, txdata : node_txn. clone ( ) } , 201 ) ;
4534
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 201 , true , header_201. bitcoin_hash ( ) ) ;
4525
4535
4526
4536
// Verify that B is able to spend its own HTLC-Success tx thanks to spendable output event given back by its ChannelMonitor
4527
4537
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
@@ -4793,7 +4803,7 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
4793
4803
// Create some initial channels
4794
4804
let chan_1 = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
4795
4805
4796
- route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 9000000 ) . 0 ;
4806
+ let ( _ , our_payment_hash ) = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 9000000 ) ;
4797
4807
let local_txn = nodes[ 0 ] . node . channel_state . lock ( ) . unwrap ( ) . by_id . get_mut ( & chan_1. 2 ) . unwrap ( ) . channel_monitor ( ) . get_latest_local_commitment_txn ( ) ;
4798
4808
assert_eq ! ( local_txn[ 0 ] . input. len( ) , 1 ) ;
4799
4809
check_spends ! ( local_txn[ 0 ] , chan_1. 3 ) ;
@@ -4813,6 +4823,15 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
4813
4823
4814
4824
let header_201 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4815
4825
nodes[ 0 ] . block_notifier . block_connected ( & Block { header : header_201, txdata : vec ! [ htlc_timeout. clone( ) ] } , 201 ) ;
4826
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 201 , true , header_201. bitcoin_hash ( ) ) ;
4827
+ let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
4828
+ assert_eq ! ( events. len( ) , 1 ) ;
4829
+ match events[ 0 ] {
4830
+ Event :: PaymentFailed { payment_hash, .. } => {
4831
+ assert_eq ! ( payment_hash, our_payment_hash) ;
4832
+ } ,
4833
+ _ => panic ! ( "Unexpected event" ) ,
4834
+ }
4816
4835
4817
4836
// Verify that A is able to spend its own HTLC-Timeout tx thanks to spendable output event given back by its ChannelMonitor
4818
4837
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
@@ -4835,12 +4854,16 @@ fn test_static_output_closing_tx() {
4835
4854
let closing_tx = close_channel ( & nodes[ 0 ] , & nodes[ 1 ] , & chan. 2 , chan. 3 , true ) . 2 ;
4836
4855
4837
4856
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4838
- nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 1 ) ;
4857
+ nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
4858
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
4859
+
4839
4860
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 2 ) ;
4840
4861
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4841
4862
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
4842
4863
4843
- nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 1 ) ;
4864
+ nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
4865
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
4866
+
4844
4867
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 2 ) ;
4845
4868
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4846
4869
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
@@ -6714,7 +6737,8 @@ fn test_data_loss_protect() {
6714
6737
check_spends ! ( node_txn[ 0 ] , chan. 3 ) ;
6715
6738
assert_eq ! ( node_txn[ 0 ] . output. len( ) , 2 ) ;
6716
6739
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
6717
- nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
6740
+ nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
6741
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
6718
6742
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
6719
6743
assert_eq ! ( spend_txn. len( ) , 1 ) ;
6720
6744
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
0 commit comments