@@ -37,7 +37,7 @@ use lightning::ln::channelmonitor::{ChannelMonitorUpdateErr, HTLCUpdate};
37
37
use lightning:: ln:: channelmanager:: { ChannelManager , PaymentHash , PaymentPreimage } ;
38
38
use lightning:: ln:: router:: { Route , RouteHop } ;
39
39
use 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} ;
41
41
use lightning:: util:: logger:: Logger ;
42
42
use lightning:: util:: config:: UserConfig ;
43
43
use lightning:: util:: events:: { EventsProvider , MessageSendEventsProvider } ;
@@ -52,6 +52,7 @@ use secp256k1::Secp256k1;
52
52
use std:: cmp:: Ordering ;
53
53
use std:: collections:: HashSet ;
54
54
use std:: sync:: { Arc , Mutex } ;
55
+ use std:: sync:: atomic;
55
56
use std:: io:: Cursor ;
56
57
57
58
struct FuzzEstimator { }
@@ -91,6 +92,8 @@ impl channelmonitor::ManyChannelMonitor for TestChannelMonitor {
91
92
92
93
struct KeyProvider {
93
94
node_id : u8 ,
95
+ session_id : atomic:: AtomicU8 ,
96
+ channel_id : atomic:: AtomicU8 ,
94
97
}
95
98
impl KeysInterface for KeyProvider {
96
99
fn get_node_secret ( & self ) -> SecretKey {
@@ -121,15 +124,13 @@ impl KeysInterface for KeyProvider {
121
124
}
122
125
123
126
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 ( )
127
129
}
128
130
129
131
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 ]
133
134
}
134
135
}
135
136
@@ -146,7 +147,7 @@ pub fn do_test(data: &[u8]) {
146
147
let watch = Arc :: new( ChainWatchInterfaceUtil :: new( Network :: Bitcoin , Arc :: clone( & logger) ) ) ;
147
148
let monitor = Arc :: new( TestChannelMonitor :: new( watch. clone( ) , broadcast. clone( ) , logger. clone( ) , fee_est. clone( ) ) ) ;
148
149
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 ) } ) ;
150
151
let mut config = UserConfig :: new( ) ;
151
152
config. channel_options. fee_proportional_millionths = 0 ;
152
153
config. channel_options. announced_channel = true ;
0 commit comments