@@ -37,7 +37,7 @@ use lightning::ln::channelmonitor::{ChannelMonitorUpdateErr, HTLCUpdate};
3737use lightning:: ln:: channelmanager:: { ChannelManager , PaymentHash , PaymentPreimage } ;
3838use lightning:: ln:: router:: { Route , RouteHop } ;
3939use lightning:: ln:: msgs:: { CommitmentUpdate , ChannelMessageHandler , ErrorAction , HandleError , UpdateAddHTLC } ;
40- use lightning:: util:: { reset_rng_state, fill_bytes , events} ;
40+ use lightning:: util:: { reset_rng_state, events} ;
4141use lightning:: util:: logger:: Logger ;
4242use lightning:: util:: config:: UserConfig ;
4343use lightning:: util:: events:: { EventsProvider , MessageSendEventsProvider } ;
@@ -52,6 +52,7 @@ use secp256k1::Secp256k1;
5252use std:: cmp:: Ordering ;
5353use std:: collections:: HashSet ;
5454use std:: sync:: { Arc , Mutex } ;
55+ use std:: sync:: atomic;
5556use std:: io:: Cursor ;
5657
5758struct FuzzEstimator { }
@@ -91,6 +92,8 @@ impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
9192
9293struct KeyProvider {
9394 node_id : u8 ,
95+ session_id : atomic:: AtomicU8 ,
96+ channel_id : atomic:: AtomicU8 ,
9497}
9598impl KeysInterface for KeyProvider {
9699 fn get_node_secret ( & self ) -> SecretKey {
@@ -121,15 +124,13 @@ impl KeysInterface for KeyProvider {
121124 }
122125
123126 fn get_session_key ( & self ) -> SecretKey {
124- let mut session_key = [ 0 ; 32 ] ;
125- fill_bytes ( & mut session_key) ;
126- SecretKey :: from_slice ( & session_key) . unwrap ( )
127+ let id = self . session_id . fetch_add ( 1 , atomic:: Ordering :: Relaxed ) ;
128+ SecretKey :: from_slice ( & [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , id, 10 , self . node_id ] ) . unwrap ( )
127129 }
128130
129131 fn get_channel_id ( & self ) -> [ u8 ; 32 ] {
130- let mut channel_id = [ 0 ; 32 ] ;
131- fill_bytes ( & mut channel_id) ;
132- channel_id
132+ let id = self . channel_id . fetch_add ( 1 , atomic:: Ordering :: Relaxed ) ;
133+ [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , id, 11 , self . node_id ]
133134 }
134135}
135136
@@ -146,7 +147,7 @@ pub fn do_test(data: &[u8]) {
146147 let watch = Arc :: new( ChainWatchInterfaceUtil :: new( Network :: Bitcoin , Arc :: clone( & logger) ) ) ;
147148 let monitor = Arc :: new( TestChannelMonitor :: new( watch. clone( ) , broadcast. clone( ) , logger. clone( ) , fee_est. clone( ) ) ) ;
148149
149- let keys_manager = Arc :: new( KeyProvider { node_id: $node_id } ) ;
150+ let keys_manager = Arc :: new( KeyProvider { node_id: $node_id, session_id : atomic :: AtomicU8 :: new ( 0 ) , channel_id : atomic :: AtomicU8 :: new ( 0 ) } ) ;
150151 let mut config = UserConfig :: new( ) ;
151152 config. channel_options. fee_proportional_millionths = 0 ;
152153 config. channel_options. announced_channel = true ;
0 commit comments