@@ -3934,7 +3934,7 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
3934
3934
}
3935
3935
3936
3936
macro_rules! check_spendable_outputs {
3937
- ( $node: expr, $der_idx: expr) => {
3937
+ ( $node: expr, $der_idx: expr, $chan_signer : expr ) => {
3938
3938
{
3939
3939
let events = $node. chan_monitor. simple_monitor. get_and_clear_pending_events( ) ;
3940
3940
let mut txn = Vec :: new( ) ;
@@ -3970,7 +3970,7 @@ macro_rules! check_spendable_outputs {
3970
3970
spend_tx. input[ 0 ] . witness. push( remotepubkey. serialize( ) . to_vec( ) ) ;
3971
3971
txn. push( spend_tx) ;
3972
3972
} ,
3973
- SpendableOutputDescriptor :: DynamicOutputP2WSH { ref outpoint, ref key , ref witness_script, ref to_self_delay, ref output } => {
3973
+ SpendableOutputDescriptor :: DynamicOutputP2WSH { ref outpoint, ref per_commitment_point , ref witness_script, ref to_self_delay, ref output } => {
3974
3974
let input = TxIn {
3975
3975
previous_output: outpoint. clone( ) ,
3976
3976
script_sig: Script :: new( ) ,
@@ -3988,12 +3988,7 @@ macro_rules! check_spendable_outputs {
3988
3988
output: vec![ outp] ,
3989
3989
} ;
3990
3990
let secp_ctx = Secp256k1 :: new( ) ;
3991
- let sighash = Message :: from_slice( & bip143:: SighashComponents :: new( & spend_tx) . sighash_all( & spend_tx. input[ 0 ] , witness_script, output. value) [ ..] ) . unwrap( ) ;
3992
- let local_delaysig = secp_ctx. sign( & sighash, key) ;
3993
- spend_tx. input[ 0 ] . witness. push( local_delaysig. serialize_der( ) . to_vec( ) ) ;
3994
- spend_tx. input[ 0 ] . witness[ 0 ] . push( SigHashType :: All as u8 ) ;
3995
- spend_tx. input[ 0 ] . witness. push( vec!( 0 ) ) ;
3996
- spend_tx. input[ 0 ] . witness. push( witness_script. clone( ) . into_bytes( ) ) ;
3991
+ $chan_signer. sign_delayed_transaction( & mut spend_tx, 0 , & witness_script, output. value, per_commitment_point, & secp_ctx) ;
3997
3992
txn. push( spend_tx) ;
3998
3993
} ,
3999
3994
SpendableOutputDescriptor :: StaticOutput { ref outpoint, ref output } => {
@@ -4066,7 +4061,8 @@ fn test_claim_sizeable_push_msat() {
4066
4061
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
4067
4062
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4068
4063
4069
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4064
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
4065
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4070
4066
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4071
4067
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4072
4068
}
@@ -4096,7 +4092,8 @@ fn test_claim_on_remote_sizeable_push_msat() {
4096
4092
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
4097
4093
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4098
4094
4099
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4095
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
4096
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4100
4097
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4101
4098
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
4102
4099
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
@@ -4129,7 +4126,8 @@ fn test_claim_on_remote_revoked_sizeable_push_msat() {
4129
4126
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4130
4127
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4131
4128
4132
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4129
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
4130
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4133
4131
assert_eq ! ( spend_txn. len( ) , 3 ) ;
4134
4132
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ; // to_remote output on revoked remote commitment_tx
4135
4133
check_spends ! ( spend_txn[ 0 ] , revoked_local_txn[ 0 ] ) ;
@@ -4180,7 +4178,8 @@ fn test_static_spendable_outputs_preimage_tx() {
4180
4178
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4181
4179
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4182
4180
4183
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4181
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4182
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4184
4183
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4185
4184
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4186
4185
}
@@ -4234,7 +4233,8 @@ fn test_static_spendable_outputs_timeout_tx() {
4234
4233
_ => panic ! ( "Unexpected event" ) ,
4235
4234
}
4236
4235
4237
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4236
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4237
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4238
4238
assert_eq ! ( spend_txn. len( ) , 3 ) ; // SpendableOutput: remote_commitment_tx.to_remote (*2), timeout_tx.output (*1)
4239
4239
check_spends ! ( spend_txn[ 2 ] , node_txn[ 0 ] . clone( ) ) ;
4240
4240
}
@@ -4270,7 +4270,8 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() {
4270
4270
nodes[ 1 ] . block_notifier . block_connected ( & Block { header : header_1, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 1 ) ;
4271
4271
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4272
4272
4273
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4273
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4274
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4274
4275
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4275
4276
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4276
4277
}
@@ -4325,7 +4326,8 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
4325
4326
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4326
4327
4327
4328
// Check B's ChannelMonitor was able to generate the right spendable output descriptor
4328
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4329
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4330
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4329
4331
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4330
4332
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4331
4333
check_spends ! ( spend_txn[ 1 ] , node_txn[ 2 ] ) ;
@@ -4375,7 +4377,8 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() {
4375
4377
connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 1 , true , header. bitcoin_hash ( ) ) ;
4376
4378
4377
4379
// Check A's ChannelMonitor was able to generate the right spendable output descriptor
4378
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
4380
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan_1. 2 ) ;
4381
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 , chan_signer) ;
4379
4382
assert_eq ! ( spend_txn. len( ) , 5 ) ; // Duplicated SpendableOutput due to block rescan after revoked htlc output tracking
4380
4383
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
4381
4384
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 2 ] ) ;
@@ -4651,7 +4654,8 @@ fn test_dynamic_spendable_outputs_local_htlc_success_tx() {
4651
4654
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 201 , true , header_201. bitcoin_hash ( ) ) ;
4652
4655
4653
4656
// Verify that B is able to spend its own HTLC-Success tx thanks to spendable output event given back by its ChannelMonitor
4654
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ;
4657
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan_1. 2 ) ;
4658
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 , chan_signer) ;
4655
4659
assert_eq ! ( spend_txn. len( ) , 2 ) ;
4656
4660
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
4657
4661
check_spends ! ( spend_txn[ 1 ] , node_txn[ 1 ] ) ;
@@ -4952,7 +4956,8 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
4952
4956
}
4953
4957
4954
4958
// Verify that A is able to spend its own HTLC-Timeout tx thanks to spendable output event given back by its ChannelMonitor
4955
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
4959
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan_1. 2 ) ;
4960
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 , chan_signer) ;
4956
4961
assert_eq ! ( spend_txn. len( ) , 3 ) ;
4957
4962
assert_eq ! ( spend_txn[ 0 ] , spend_txn[ 1 ] ) ;
4958
4963
check_spends ! ( spend_txn[ 0 ] , local_txn[ 0 ] ) ;
@@ -4975,14 +4980,16 @@ fn test_static_output_closing_tx() {
4975
4980
nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
4976
4981
connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
4977
4982
4978
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 2 ) ;
4983
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan. 2 ) ;
4984
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 2 , chan_signer) ;
4979
4985
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4980
4986
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
4981
4987
4982
4988
nodes[ 1 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ closing_tx. clone( ) ] } , 0 ) ;
4983
4989
connect_blocks ( & nodes[ 1 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
4984
4990
4985
- let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 2 ) ;
4991
+ let chan_signer = get_chan_signer ! ( nodes[ 1 ] , chan. 2 ) ;
4992
+ let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 2 , chan_signer) ;
4986
4993
assert_eq ! ( spend_txn. len( ) , 1 ) ;
4987
4994
check_spends ! ( spend_txn[ 0 ] , closing_tx) ;
4988
4995
}
@@ -6835,7 +6842,8 @@ fn test_data_loss_protect() {
6835
6842
let header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
6836
6843
nodes[ 0 ] . block_notifier . block_connected ( & Block { header, txdata : vec ! [ node_txn[ 0 ] . clone( ) ] } , 0 ) ;
6837
6844
connect_blocks ( & nodes[ 0 ] . block_notifier , ANTI_REORG_DELAY - 1 , 0 , true , header. bitcoin_hash ( ) ) ;
6838
- let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 ) ;
6845
+ let chan_signer = get_chan_signer ! ( nodes[ 0 ] , chan. 2 ) ;
6846
+ let spend_txn = check_spendable_outputs ! ( nodes[ 0 ] , 1 , chan_signer) ;
6839
6847
assert_eq ! ( spend_txn. len( ) , 1 ) ;
6840
6848
check_spends ! ( spend_txn[ 0 ] , node_txn[ 0 ] ) ;
6841
6849
}
0 commit comments