@@ -4049,6 +4049,8 @@ fn test_claim_sizeable_push_msat() {
4049
4049
4050
4050
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4051
4051
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
4052
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4053
+
4052
4054
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4053
4055
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4054
4056
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
@@ -4077,6 +4079,8 @@ fn test_claim_on_remote_sizeable_push_msat() {
4077
4079
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
4078
4080
check_closed_broadcast ! ( nodes[ 1 ] , false ) ;
4079
4081
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
4082
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4083
+
4080
4084
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4081
4085
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4082
4086
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
@@ -4101,13 +4105,14 @@ fn test_claim_on_remote_revoked_sizeable_push_msat() {
4101
4105
4102
4106
claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , payment_preimage, 3_000_000 ) ;
4103
4107
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4104
- nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone( ) ] } , 1 ) ;
4108
+ nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone( ) ] } , 0 ) ;
4105
4109
check_closed_broadcast ! ( nodes[ 1 ] , false ) ;
4106
4110
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
4107
4111
4108
4112
let node_txn = nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
4109
4113
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4110
- nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 2 ) ;
4114
+ nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4115
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4111
4116
4112
4117
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4113
4118
assert_eq ! ( spend_txn. len( ) , 3 ) ;
@@ -4158,6 +4163,7 @@ fn test_static_spendable_outputs_preimage_tx() {
4158
4163
4159
4164
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4160
4165
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4166
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4161
4167
4162
4168
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4163
4169
assert_eq ! ( spend_txn. len( ) , 1 ) ;
@@ -4182,7 +4188,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() {
4182
4188
claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , payment_preimage, 3_000_000 ) ;
4183
4189
4184
4190
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4185
- nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone( ) ] } , 1 ) ;
4191
+ nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ revoked_local_txn[ 0 ] . clone( ) ] } , 0 ) ;
4186
4192
check_closed_broadcast ! ( nodes[ 1 ] , false ) ;
4187
4193
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
4188
4194
@@ -4192,7 +4198,8 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() {
4192
4198
check_spends ! ( node_txn[ 0 ] , revoked_local_txn[ 0 ] ) ;
4193
4199
4194
4200
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4195
- nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 2 ) ;
4201
+ nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4202
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4196
4203
4197
4204
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4198
4205
assert_eq ! ( spend_txn. len( ) , 1 ) ;
@@ -4247,6 +4254,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
4247
4254
4248
4255
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4249
4256
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) , node_txn[ 2 ] . clone( ) ] } , 1 ) ;
4257
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4250
4258
4251
4259
// Check B's ChannelMonitor was able to generate the right spendable output descriptor
4252
4260
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
@@ -4297,6 +4305,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() {
4297
4305
4298
4306
let header_1 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4299
4307
nodes[ 0 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) , node_txn[ 2 ] . clone( ) ] } , 1 ) ;
4308
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4300
4309
4301
4310
// Check A's ChannelMonitor was able to generate the right spendable output descriptor
4302
4311
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
@@ -4573,6 +4582,7 @@ fn test_dynamic_spendable_outputs_local_htlc_success_tx() {
4573
4582
4574
4583
let header_201 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4575
4584
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_201, txdata : node_txn. clone ( ) } , 201 ) ;
4585
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 201 , true , header_201. bitcoin_hash ( ) ) ;
4576
4586
4577
4587
// Verify that B is able to spend its own HTLC-Success tx thanks to spendable output event given back by its ChannelMonitor
4578
4588
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
@@ -4844,7 +4854,7 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
4844
4854
// Create some initial channels
4845
4855
let chan_1 = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: supported ( ) , InitFeatures :: supported ( ) ) ;
4846
4856
4847
- route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 9000000 ) . 0 ;
4857
+ let ( _ , our_payment_hash ) = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 9000000 ) ;
4848
4858
let local_txn = get_local_commitment_txn ! ( nodes[ 0 ] , chan_1. 2 ) ;
4849
4859
assert_eq ! ( local_txn[ 0 ] . input. len( ) , 1 ) ;
4850
4860
check_spends ! ( local_txn[ 0 ] , chan_1. 3 ) ;
@@ -4865,6 +4875,15 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
4865
4875
4866
4876
let header_201 = BlockHeader { version : 0x20000000 , prev_blockhash : header. bitcoin_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4867
4877
nodes[ 0 ] . block_notifier . block_connected ( & Block { header : header_201, txdata : vec ! [ htlc_timeout. clone( ) ] } , 201 ) ;
4878
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 201 , true , header_201. bitcoin_hash ( ) ) ;
4879
+ let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
4880
+ assert_eq ! ( events. len( ) , 1 ) ;
4881
+ match events[ 0 ] {
4882
+ Event :: PaymentFailed { payment_hash, .. } => {
4883
+ assert_eq ! ( payment_hash, our_payment_hash) ;
4884
+ } ,
4885
+ _ => panic ! ( "Unexpected event" ) ,
4886
+ }
4868
4887
4869
4888
// Verify that A is able to spend its own HTLC-Timeout tx thanks to spendable output event given back by its ChannelMonitor
4870
4889
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
@@ -4887,12 +4906,16 @@ fn test_static_output_closing_tx() {
4887
4906
let closing_tx = close_channel ( & nodes[ 0 ] , & nodes[ 1 ] , & chan. 2 , chan. 3 , true ) . 2 ;
4888
4907
4889
4908
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
4890
- nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 1 ) ;
4909
+ nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
4910
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
4911
+
4891
4912
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 2 ) ;
4892
4913
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4893
4914
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
4894
4915
4895
- nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 1 ) ;
4916
+ nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
4917
+ connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
4918
+
4896
4919
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 2 ) ;
4897
4920
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4898
4921
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
@@ -6744,7 +6767,8 @@ fn test_data_loss_protect() {
6744
6767
check_spends ! ( node_txn[ 0 ] , chan. 3 ) ;
6745
6768
assert_eq ! ( node_txn[ 0 ] . output. len( ) , 2 ) ;
6746
6769
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
6747
- nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
6770
+ nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
6771
+ connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
6748
6772
let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
6749
6773
assert_eq ! ( spend_txn. len( ) , 1 ) ;
6750
6774
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
0 commit comments