@@ -4087,7 +4087,7 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
4087
4087
}
4088
4088
4089
4089
macro_rules! check_spendable_outputs {
4090
- ( $node: expr, $der_idx: expr) => {
4090
+ ( $node: expr, $der_idx: expr, $chan_signer : expr ) => {
4091
4091
{
4092
4092
let events = $node. chan_monitor. simple_monitor. get_and_clear_pending_events( ) ;
4093
4093
let mut txn = Vec :: new( ) ;
@@ -4123,7 +4123,7 @@ macro_rules! check_spendable_outputs {
4123
4123
spend_tx. input[ 0 ] . witness. push( remotepubkey. serialize( ) . to_vec( ) ) ;
4124
4124
txn. push( spend_tx) ;
4125
4125
} ,
4126
- SpendableOutputDescriptor :: DynamicOutputP2WSH { ref outpoint, ref key , ref witness_script, ref to_self_delay, ref output } => {
4126
+ SpendableOutputDescriptor :: DynamicOutputP2WSH { ref outpoint, ref per_commitment_point , ref witness_script, ref to_self_delay, ref output } => {
4127
4127
let input = TxIn {
4128
4128
previous_output: outpoint. clone( ) ,
4129
4129
script_sig: Script :: new( ) ,
@@ -4141,12 +4141,7 @@ macro_rules! check_spendable_outputs {
4141
4141
output: vec![ outp] ,
4142
4142
} ;
4143
4143
let secp_ctx = Secp256k1 :: new( ) ;
4144
- let sighash = Message :: from_slice( & bip143:: SighashComponents :: new( & spend_tx) . sighash_all( & spend_tx. input[ 0 ] , witness_script, output. value) [ ..] ) . unwrap( ) ;
4145
- let local_delaysig = secp_ctx. sign( & sighash, key) ;
4146
- spend_tx. input[ 0 ] . witness. push( local_delaysig. serialize_der( ) . to_vec( ) ) ;
4147
- spend_tx. input[ 0 ] . witness[ 0 ] . push( SigHashType :: All as u8 ) ;
4148
- spend_tx. input[ 0 ] . witness. push( vec!( ) ) ;
4149
- spend_tx. input[ 0 ] . witness. push( witness_script. clone( ) . into_bytes( ) ) ;
4144
+ $chan_signer. sign_delayed_transaction( & mut spend_tx, 0 , & witness_script, output. value, per_commitment_point, & secp_ctx) ;
4150
4145
txn. push( spend_tx) ;
4151
4146
} ,
4152
4147
SpendableOutputDescriptor :: StaticOutput { ref outpoint, ref output } => {
@@ -4219,7 +4214,8 @@ fn test_claim_sizeable_push_msat() {
4219
4214
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
4220
4215
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4221
4216
4222
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4217
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
4218
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4223
4219
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4224
4220
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4225
4221
}
@@ -4249,7 +4245,8 @@ fn test_claim_on_remote_sizeable_push_msat() {
4249
4245
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
4250
4246
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4251
4247
4252
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4248
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
4249
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4253
4250
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4254
4251
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
4255
4252
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
@@ -4282,7 +4279,8 @@ fn test_claim_on_remote_revoked_sizeable_push_msat() {
4282
4279
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4283
4280
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4284
4281
4285
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4282
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
4283
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4286
4284
assert_eq ! ( spend_txn. len( ) , 3 ) ;
4287
4285
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ; // to_remote output on revoked remote commitment_tx
4288
4286
check_spends ! ( spend_txn[ 0 ] , revoked_local_txn[ 0 ] ) ;
@@ -4333,7 +4331,8 @@ fn test_static_spendable_outputs_preimage_tx() {
4333
4331
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4334
4332
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4335
4333
4336
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4334
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4335
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4337
4336
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4338
4337
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4339
4338
}
@@ -4380,7 +4379,8 @@ fn test_static_spendable_outputs_timeout_tx() {
4380
4379
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4381
4380
expect_payment_failed ! ( nodes[ 1 ] , our_payment_hash, true ) ;
4382
4381
4383
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4382
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4383
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4384
4384
assert_eq ! ( spend_txn. len( ) , 3 ) ; // SpendableOutput: remote_commitment_tx.to_remote (*2), timeout_tx.output (*1)
4385
4385
check_spends ! ( spend_txn[ 2 ] , node_txn[ 0 ] . clone( ) ) ;
4386
4386
}
@@ -4416,7 +4416,8 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() {
4416
4416
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4417
4417
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4418
4418
4419
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4419
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4420
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4420
4421
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4421
4422
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4422
4423
}
@@ -4471,7 +4472,8 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
4471
4472
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4472
4473
4473
4474
// Check B's ChannelMonitor was able to generate the right spendable output descriptor
4474
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4475
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4476
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4475
4477
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4476
4478
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4477
4479
check_spends ! ( spend_txn[ 1 ] , node_txn[ 2 ] ) ;
@@ -4521,7 +4523,8 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() {
4521
4523
connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4522
4524
4523
4525
// Check A's ChannelMonitor was able to generate the right spendable output descriptor
4524
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
4526
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan_1. 2 ) ;
4527
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 , chan_signer) ;
4525
4528
assert_eq ! ( spend_txn. len( ) , 5 ) ; // Duplicated SpendableOutput due to block rescan after revoked htlc output tracking
4526
4529
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
4527
4530
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 2 ] ) ;
@@ -4791,7 +4794,8 @@ fn test_dynamic_spendable_outputs_local_htlc_success_tx() {
4791
4794
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 201 , true , header_201. bitcoin_hash ( ) ) ;
4792
4795
4793
4796
// Verify that B is able to spend its own HTLC-Success tx thanks to spendable output event given back by its ChannelMonitor
4794
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4797
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4798
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4795
4799
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4796
4800
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4797
4801
check_spends ! ( spend_txn[ 1 ] , node_txn[ 1 ] ) ;
@@ -5085,7 +5089,8 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
5085
5089
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true ) ;
5086
5090
5087
5091
// Verify that A is able to spend its own HTLC-Timeout tx thanks to spendable output event given back by its ChannelMonitor
5088
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
5092
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan_1. 2 ) ;
5093
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 , chan_signer) ;
5089
5094
assert_eq ! ( spend_txn. len( ) , 3 ) ;
5090
5095
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
5091
5096
check_spends ! ( spend_txn[ 0 ] , local_txn[ 0 ] ) ;
@@ -5108,14 +5113,16 @@ fn test_static_output_closing_tx() {
5108
5113
nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
5109
5114
connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
5110
5115
5111
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 2 ) ;
5116
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan. 2 ) ;
5117
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 2 , chan_signer) ;
5112
5118
assert_eq ! ( spend_txn. len( ) , 1 ) ;
5113
5119
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
5114
5120
5115
5121
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
5116
5122
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
5117
5123
5118
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 2 ) ;
5124
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
5125
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 2 , chan_signer) ;
5119
5126
assert_eq ! ( spend_txn. len( ) , 1 ) ;
5120
5127
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
5121
5128
}
@@ -6909,7 +6916,8 @@ fn test_data_loss_protect() {
6909
6916
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
6910
6917
nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
6911
6918
connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
6912
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
6919
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan. 2 ) ;
6920
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 , chan_signer) ;
6913
6921
assert_eq ! ( spend_txn. len( ) , 1 ) ;
6914
6922
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
6915
6923
}
0 commit comments