@@ -1599,29 +1599,29 @@ fn test_fee_spike_violation_fails_htlc() {
1599
1599
1600
1600
let feerate_per_kw = get_feerate ! ( nodes[ 0 ] , chan. 2 ) ;
1601
1601
1602
+ const INITIAL_COMMITMENT_NUMBER : u64 = ( 1 << 48 ) - 1 ;
1603
+
1602
1604
// Get the EnforcingChannelKeys for each channel, which will be used to (1) get the keys
1603
1605
// needed to sign the new commitment tx and (2) sign the new commitment tx.
1604
- let ( local_revocation_basepoint, local_htlc_basepoint, local_payment_point, local_chan_commitment_seed ) = {
1606
+ let ( local_revocation_basepoint, local_htlc_basepoint, local_payment_point, local_secret , local_secret2 ) = {
1605
1607
let chan_lock = nodes[ 0 ] . node . channel_state . lock ( ) . unwrap ( ) ;
1606
1608
let local_chan = chan_lock. by_id . get ( & chan. 2 ) . unwrap ( ) ;
1607
1609
let chan_keys = local_chan. get_local_keys ( ) ;
1608
1610
let pubkeys = chan_keys. pubkeys ( ) ;
1609
- ( pubkeys. revocation_basepoint , pubkeys. htlc_basepoint , pubkeys. payment_point , * chan_keys. commitment_seed ( ) )
1611
+ ( pubkeys. revocation_basepoint , pubkeys. htlc_basepoint , pubkeys. payment_point ,
1612
+ chan_keys. commitment_secret ( INITIAL_COMMITMENT_NUMBER ) , chan_keys. commitment_secret ( INITIAL_COMMITMENT_NUMBER - 2 ) )
1610
1613
} ;
1611
- let ( remote_delayed_payment_basepoint, remote_htlc_basepoint, remote_payment_point, remote_chan_commitment_seed ) = {
1614
+ let ( remote_delayed_payment_basepoint, remote_htlc_basepoint, remote_payment_point, remote_secret1 ) = {
1612
1615
let chan_lock = nodes[ 1 ] . node . channel_state . lock ( ) . unwrap ( ) ;
1613
1616
let remote_chan = chan_lock. by_id . get ( & chan. 2 ) . unwrap ( ) ;
1614
1617
let chan_keys = remote_chan. get_local_keys ( ) ;
1615
1618
let pubkeys = chan_keys. pubkeys ( ) ;
1616
- ( pubkeys. delayed_payment_basepoint , pubkeys. htlc_basepoint , pubkeys. payment_point , * chan_keys. commitment_seed ( ) )
1619
+ ( pubkeys. delayed_payment_basepoint , pubkeys. htlc_basepoint , pubkeys. payment_point ,
1620
+ chan_keys. commitment_secret ( INITIAL_COMMITMENT_NUMBER - 1 ) )
1617
1621
} ;
1618
1622
1619
1623
// Assemble the set of keys we can use for signatures for our commitment_signed message.
1620
- const INITIAL_COMMITMENT_NUMBER : u64 = ( 1 << 48 ) - 1 ;
1621
- let commitment_secret = {
1622
- let res = chan_utils:: build_commitment_secret ( & remote_chan_commitment_seed, INITIAL_COMMITMENT_NUMBER - 1 ) ;
1623
- SecretKey :: from_slice ( & res) . unwrap ( )
1624
- } ;
1624
+ let commitment_secret = SecretKey :: from_slice ( & remote_secret1) . unwrap ( ) ;
1625
1625
let per_commitment_point = PublicKey :: from_secret_key ( & secp_ctx, & commitment_secret) ;
1626
1626
let commit_tx_keys = chan_utils:: TxCreationKeys :: new ( & secp_ctx, & per_commitment_point, & remote_delayed_payment_basepoint,
1627
1627
& remote_htlc_basepoint, & local_revocation_basepoint, & local_htlc_basepoint) . unwrap ( ) ;
@@ -1706,8 +1706,8 @@ fn test_fee_spike_violation_fails_htlc() {
1706
1706
let _ = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
1707
1707
1708
1708
// Send the RAA to nodes[1].
1709
- let per_commitment_secret = chan_utils :: build_commitment_secret ( & local_chan_commitment_seed , INITIAL_COMMITMENT_NUMBER ) ;
1710
- let next_secret = SecretKey :: from_slice ( & chan_utils :: build_commitment_secret ( & local_chan_commitment_seed , INITIAL_COMMITMENT_NUMBER - 2 ) ) . unwrap ( ) ;
1709
+ let per_commitment_secret = local_secret ;
1710
+ let next_secret = SecretKey :: from_slice ( & local_secret2 ) . unwrap ( ) ;
1711
1711
let next_per_commitment_point = PublicKey :: from_secret_key ( & secp_ctx, & next_secret) ;
1712
1712
let raa_msg = msgs:: RevokeAndACK { channel_id : chan. 2 , per_commitment_secret, next_per_commitment_point} ;
1713
1713
nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 0 ] . node . get_our_node_id ( ) , & raa_msg) ;
@@ -8125,11 +8125,12 @@ fn test_counterparty_raa_skip_no_crash() {
8125
8125
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
8126
8126
let channel_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 2 ;
8127
8127
8128
- let commitment_seed = nodes[ 0 ] . node . channel_state . lock ( ) . unwrap ( ) . by_id . get_mut ( & channel_id) . unwrap ( ) . local_keys . commitment_seed ( ) . clone ( ) ;
8128
+ let mut guard = nodes[ 0 ] . node . channel_state . lock ( ) . unwrap ( ) ;
8129
+ let local_keys = & guard. by_id . get_mut ( & channel_id) . unwrap ( ) . local_keys ;
8129
8130
const INITIAL_COMMITMENT_NUMBER : u64 = ( 1 << 48 ) - 1 ;
8130
8131
let next_per_commitment_point = PublicKey :: from_secret_key ( & Secp256k1 :: new ( ) ,
8131
- & SecretKey :: from_slice ( & chan_utils :: build_commitment_secret ( & commitment_seed , INITIAL_COMMITMENT_NUMBER - 2 ) ) . unwrap ( ) ) ;
8132
- let per_commitment_secret = chan_utils :: build_commitment_secret ( & commitment_seed , INITIAL_COMMITMENT_NUMBER ) ;
8132
+ & SecretKey :: from_slice ( & local_keys . commitment_secret ( INITIAL_COMMITMENT_NUMBER - 2 ) ) . unwrap ( ) ) ;
8133
+ let per_commitment_secret = local_keys . commitment_secret ( INITIAL_COMMITMENT_NUMBER ) ;
8133
8134
8134
8135
nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 0 ] . node . get_our_node_id ( ) ,
8135
8136
& msgs:: RevokeAndACK { channel_id, per_commitment_secret, next_per_commitment_point } ) ;
0 commit comments