@@ -1617,27 +1617,26 @@ fn test_fee_spike_violation_fails_htlc() {
1617
1617
1618
1618
// Get the EnforcingChannelKeys for each channel, which will be used to (1) get the keys
1619
1619
// needed to sign the new commitment tx and (2) sign the new commitment tx.
1620
- let ( local_revocation_basepoint, local_htlc_basepoint, local_payment_point, local_secret, local_secret2 ) = {
1620
+ let ( local_revocation_basepoint, local_htlc_basepoint, local_payment_point, local_secret, next_local_point ) = {
1621
1621
let chan_lock = nodes[ 0 ] . node . channel_state . lock ( ) . unwrap ( ) ;
1622
1622
let local_chan = chan_lock. by_id . get ( & chan. 2 ) . unwrap ( ) ;
1623
1623
let chan_keys = local_chan. get_keys ( ) ;
1624
1624
let pubkeys = chan_keys. pubkeys ( ) ;
1625
1625
( pubkeys. revocation_basepoint , pubkeys. htlc_basepoint , pubkeys. payment_point ,
1626
- chan_keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER ) , chan_keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER - 2 ) )
1626
+ chan_keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER ) ,
1627
+ chan_keys. get_per_commitment_point ( INITIAL_COMMITMENT_NUMBER - 2 , & secp_ctx) )
1627
1628
} ;
1628
- let ( remote_delayed_payment_basepoint, remote_htlc_basepoint, remote_payment_point, remote_secret1 ) = {
1629
+ let ( remote_delayed_payment_basepoint, remote_htlc_basepoint, remote_payment_point, remote_point ) = {
1629
1630
let chan_lock = nodes[ 1 ] . node . channel_state . lock ( ) . unwrap ( ) ;
1630
1631
let remote_chan = chan_lock. by_id . get ( & chan. 2 ) . unwrap ( ) ;
1631
1632
let chan_keys = remote_chan. get_keys ( ) ;
1632
1633
let pubkeys = chan_keys. pubkeys ( ) ;
1633
1634
( pubkeys. delayed_payment_basepoint , pubkeys. htlc_basepoint , pubkeys. payment_point ,
1634
- chan_keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER - 1 ) )
1635
+ chan_keys. get_per_commitment_point ( INITIAL_COMMITMENT_NUMBER - 1 , & secp_ctx ) )
1635
1636
} ;
1636
1637
1637
1638
// Assemble the set of keys we can use for signatures for our commitment_signed message.
1638
- let commitment_secret = SecretKey :: from_slice ( & remote_secret1) . unwrap ( ) ;
1639
- let per_commitment_point = PublicKey :: from_secret_key ( & secp_ctx, & commitment_secret) ;
1640
- let commit_tx_keys = chan_utils:: TxCreationKeys :: derive_new ( & secp_ctx, & per_commitment_point, & remote_delayed_payment_basepoint,
1639
+ let commit_tx_keys = chan_utils:: TxCreationKeys :: derive_new ( & secp_ctx, & remote_point, & remote_delayed_payment_basepoint,
1641
1640
& remote_htlc_basepoint, & local_revocation_basepoint, & local_htlc_basepoint) . unwrap ( ) ;
1642
1641
1643
1642
// Build the remote commitment transaction so we can sign it, and then later use the
@@ -1720,10 +1719,11 @@ fn test_fee_spike_violation_fails_htlc() {
1720
1719
let _ = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1721
1720
1722
1721
// Send the RAA to nodes[1].
1723
- let per_commitment_secret = local_secret;
1724
- let next_secret = SecretKey :: from_slice ( & local_secret2) . unwrap ( ) ;
1725
- let next_per_commitment_point = PublicKey :: from_secret_key ( & secp_ctx, & next_secret) ;
1726
- let raa_msg = msgs:: RevokeAndACK { channel_id : chan. 2 , per_commitment_secret, next_per_commitment_point} ;
1722
+ let raa_msg = msgs:: RevokeAndACK {
1723
+ channel_id : chan. 2 ,
1724
+ per_commitment_secret : local_secret,
1725
+ next_per_commitment_point : next_local_point
1726
+ } ;
1727
1727
nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 0 ] . node . get_our_node_id ( ) , & raa_msg) ;
1728
1728
1729
1729
let events = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
@@ -4309,7 +4309,6 @@ fn test_no_txn_manager_serialize_deserialize() {
4309
4309
let fee_estimator: test_utils:: TestFeeEstimator ;
4310
4310
let persister: test_utils:: TestPersister ;
4311
4311
let new_chain_monitor: test_utils:: TestChainMonitor ;
4312
- let keys_manager: test_utils:: TestKeysInterface ;
4313
4312
let nodes_0_deserialized: ChannelManager < EnforcingChannelKeys , & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ;
4314
4313
let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
4315
4314
@@ -4324,12 +4323,12 @@ fn test_no_txn_manager_serialize_deserialize() {
4324
4323
logger = test_utils:: TestLogger :: new ( ) ;
4325
4324
fee_estimator = test_utils:: TestFeeEstimator { sat_per_kw : 253 } ;
4326
4325
persister = test_utils:: TestPersister :: new ( ) ;
4327
- keys_manager = test_utils :: TestKeysInterface :: new ( & nodes [ 0 ] . node_seed , Network :: Testnet ) ;
4328
- new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister, & keys_manager) ;
4326
+ let keys_manager = & chanmon_cfgs [ 0 ] . keys_manager ;
4327
+ new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister, keys_manager) ;
4329
4328
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4330
4329
let mut chan_0_monitor_read = & chan_0_monitor_serialized. 0 [ ..] ;
4331
4330
let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read (
4332
- & mut chan_0_monitor_read, & keys_manager) . unwrap ( ) ;
4331
+ & mut chan_0_monitor_read, keys_manager) . unwrap ( ) ;
4333
4332
assert ! ( chan_0_monitor_read. is_empty( ) ) ;
4334
4333
4335
4334
let mut nodes_0_read = & nodes_0_serialized[ ..] ;
@@ -4339,7 +4338,7 @@ fn test_no_txn_manager_serialize_deserialize() {
4339
4338
channel_monitors. insert ( chan_0_monitor. get_funding_txo ( ) . 0 , & mut chan_0_monitor) ;
4340
4339
<( BlockHash , ChannelManager < EnforcingChannelKeys , & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ) >:: read ( & mut nodes_0_read, ChannelManagerReadArgs {
4341
4340
default_config : config,
4342
- keys_manager : & keys_manager ,
4341
+ keys_manager,
4343
4342
fee_estimator : & fee_estimator,
4344
4343
chain_monitor : nodes[ 0 ] . chain_monitor ,
4345
4344
tx_broadcaster : nodes[ 0 ] . tx_broadcaster . clone ( ) ,
@@ -4386,7 +4385,6 @@ fn test_manager_serialize_deserialize_events() {
4386
4385
let persister: test_utils:: TestPersister ;
4387
4386
let logger: test_utils:: TestLogger ;
4388
4387
let new_chain_monitor: test_utils:: TestChainMonitor ;
4389
- let keys_manager: test_utils:: TestKeysInterface ;
4390
4388
let nodes_0_deserialized: ChannelManager < EnforcingChannelKeys , & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ;
4391
4389
let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
4392
4390
@@ -4395,8 +4393,8 @@ fn test_manager_serialize_deserialize_events() {
4395
4393
let push_msat = 10001 ;
4396
4394
let a_flags = InitFeatures :: known ( ) ;
4397
4395
let b_flags = InitFeatures :: known ( ) ;
4398
- let node_a = nodes. pop ( ) . unwrap ( ) ;
4399
- let node_b = nodes. pop ( ) . unwrap ( ) ;
4396
+ let node_a = nodes. remove ( 0 ) ;
4397
+ let node_b = nodes. remove ( 0 ) ;
4400
4398
node_a. node . create_channel ( node_b. node . get_our_node_id ( ) , channel_value, push_msat, 42 , None ) . unwrap ( ) ;
4401
4399
node_b. node . handle_open_channel ( & node_a. node . get_our_node_id ( ) , a_flags, & get_event_msg ! ( node_a, MessageSendEvent :: SendOpenChannel , node_b. node. get_our_node_id( ) ) ) ;
4402
4400
node_a. node . handle_accept_channel ( & node_b. node . get_our_node_id ( ) , b_flags, & get_event_msg ! ( node_b, MessageSendEvent :: SendAcceptChannel , node_a. node. get_our_node_id( ) ) ) ;
@@ -4434,12 +4432,12 @@ fn test_manager_serialize_deserialize_events() {
4434
4432
fee_estimator = test_utils:: TestFeeEstimator { sat_per_kw : 253 } ;
4435
4433
logger = test_utils:: TestLogger :: new ( ) ;
4436
4434
persister = test_utils:: TestPersister :: new ( ) ;
4437
- keys_manager = test_utils :: TestKeysInterface :: new ( & nodes [ 0 ] . node_seed , Network :: Testnet ) ;
4438
- new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister, & keys_manager) ;
4435
+ let keys_manager = & chanmon_cfgs [ 0 ] . keys_manager ;
4436
+ new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister, keys_manager) ;
4439
4437
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4440
4438
let mut chan_0_monitor_read = & chan_0_monitor_serialized. 0 [ ..] ;
4441
4439
let ( _, mut chan_0_monitor) = <( BlockHash , ChannelMonitor < EnforcingChannelKeys > ) >:: read (
4442
- & mut chan_0_monitor_read, & keys_manager) . unwrap ( ) ;
4440
+ & mut chan_0_monitor_read, keys_manager) . unwrap ( ) ;
4443
4441
assert ! ( chan_0_monitor_read. is_empty( ) ) ;
4444
4442
4445
4443
let mut nodes_0_read = & nodes_0_serialized[ ..] ;
@@ -4449,7 +4447,7 @@ fn test_manager_serialize_deserialize_events() {
4449
4447
channel_monitors. insert ( chan_0_monitor. get_funding_txo ( ) . 0 , & mut chan_0_monitor) ;
4450
4448
<( BlockHash , ChannelManager < EnforcingChannelKeys , & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ) >:: read ( & mut nodes_0_read, ChannelManagerReadArgs {
4451
4449
default_config : config,
4452
- keys_manager : & keys_manager ,
4450
+ keys_manager,
4453
4451
fee_estimator : & fee_estimator,
4454
4452
chain_monitor : nodes[ 0 ] . chain_monitor ,
4455
4453
tx_broadcaster : nodes[ 0 ] . tx_broadcaster . clone ( ) ,
@@ -4510,7 +4508,6 @@ fn test_simple_manager_serialize_deserialize() {
4510
4508
let fee_estimator: test_utils:: TestFeeEstimator ;
4511
4509
let persister: test_utils:: TestPersister ;
4512
4510
let new_chain_monitor: test_utils:: TestChainMonitor ;
4513
- let keys_manager: & test_utils:: TestKeysInterface ;
4514
4511
let nodes_0_deserialized: ChannelManager < EnforcingChannelKeys , & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ;
4515
4512
let mut nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
4516
4513
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
@@ -4527,7 +4524,7 @@ fn test_simple_manager_serialize_deserialize() {
4527
4524
logger = test_utils:: TestLogger :: new ( ) ;
4528
4525
fee_estimator = test_utils:: TestFeeEstimator { sat_per_kw : 253 } ;
4529
4526
persister = test_utils:: TestPersister :: new ( ) ;
4530
- keys_manager = & chanmon_cfgs[ 0 ] . keys_manager ;
4527
+ let keys_manager = & chanmon_cfgs[ 0 ] . keys_manager ;
4531
4528
new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister, keys_manager) ;
4532
4529
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4533
4530
let mut chan_0_monitor_read = & chan_0_monitor_serialized. 0 [ ..] ;
@@ -4572,7 +4569,6 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
4572
4569
let fee_estimator: test_utils:: TestFeeEstimator ;
4573
4570
let persister: test_utils:: TestPersister ;
4574
4571
let new_chain_monitor: test_utils:: TestChainMonitor ;
4575
- let keys_manager: & test_utils:: TestKeysInterface ;
4576
4572
let nodes_0_deserialized: ChannelManager < EnforcingChannelKeys , & test_utils:: TestChainMonitor , & test_utils:: TestBroadcaster , & test_utils:: TestKeysInterface , & test_utils:: TestFeeEstimator , & test_utils:: TestLogger > ;
4577
4573
let mut nodes = create_network ( 4 , & node_cfgs, & node_chanmgrs) ;
4578
4574
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
@@ -4608,7 +4604,7 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
4608
4604
logger = test_utils:: TestLogger :: new ( ) ;
4609
4605
fee_estimator = test_utils:: TestFeeEstimator { sat_per_kw : 253 } ;
4610
4606
persister = test_utils:: TestPersister :: new ( ) ;
4611
- keys_manager = & chanmon_cfgs[ 0 ] . keys_manager ;
4607
+ let keys_manager = & chanmon_cfgs[ 0 ] . keys_manager ;
4612
4608
new_chain_monitor = test_utils:: TestChainMonitor :: new ( Some ( nodes[ 0 ] . chain_source ) , nodes[ 0 ] . tx_broadcaster . clone ( ) , & logger, & fee_estimator, & persister, keys_manager) ;
4613
4609
nodes[ 0 ] . chain_monitor = & new_chain_monitor;
4614
4610
@@ -8126,9 +8122,11 @@ fn test_counterparty_raa_skip_no_crash() {
8126
8122
let mut guard = nodes[ 0 ] . node . channel_state . lock ( ) . unwrap ( ) ;
8127
8123
let keys = & guard. by_id . get_mut ( & channel_id) . unwrap ( ) . holder_keys ;
8128
8124
const INITIAL_COMMITMENT_NUMBER : u64 = ( 1 << 48 ) - 1 ;
8125
+ let per_commitment_secret = keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER ) ;
8126
+ // Must revoke without gaps
8127
+ keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER - 1 ) ;
8129
8128
let next_per_commitment_point = PublicKey :: from_secret_key ( & Secp256k1 :: new ( ) ,
8130
8129
& SecretKey :: from_slice ( & keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER - 2 ) ) . unwrap ( ) ) ;
8131
- let per_commitment_secret = keys. release_commitment_secret ( INITIAL_COMMITMENT_NUMBER ) ;
8132
8130
8133
8131
nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 0 ] . node . get_our_node_id ( ) ,
8134
8132
& msgs:: RevokeAndACK { channel_id, per_commitment_secret, next_per_commitment_point } ) ;
0 commit comments