1919 reqwest:: Client ,
2020 serde:: Deserialize ,
2121 std:: {
22+ path:: PathBuf ,
2223 sync:: Arc ,
2324 time:: Duration ,
2425 } ,
@@ -48,7 +49,7 @@ pub struct Config {
4849 pub relayer_urls : Vec < Url > ,
4950 pub publisher_id : u32 ,
5051 pub authorization_token : String ,
51- publisher_secret_key : PublisherSecretKey ,
52+ pub publish_keypair_path : PathBuf ,
5253 #[ serde( with = "humantime_serde" , default = "default_publish_interval" ) ]
5354 pub publish_interval_duration : Duration ,
5455}
@@ -173,7 +174,10 @@ mod lazer_exporter {
173174 } ,
174175 state:: local:: LocalStore ,
175176 } ,
176- anyhow:: bail,
177+ anyhow:: {
178+ Context ,
179+ bail,
180+ } ,
177181 ed25519_dalek:: {
178182 Signer ,
179183 SigningKey ,
@@ -198,6 +202,7 @@ mod lazer_exporter {
198202 lazer_transaction:: Payload ,
199203 } ,
200204 } ,
205+ solana_sdk:: signer:: keypair,
201206 std:: {
202207 collections:: HashMap ,
203208 sync:: Arc ,
@@ -260,7 +265,21 @@ mod lazer_exporter {
260265 stream_map. insert ( config. relayer_urls [ i] . clone ( ) , receiver) ;
261266 }
262267
263- let signing_key = SigningKey :: from_bytes ( & config. publisher_secret_key . 0 ) ;
268+ // Read the keypair from the file using Solana SDK because it's the same key used by the Pythnet publisher
269+ let publish_keypair = match keypair:: read_keypair_file ( & config. publish_keypair_path ) {
270+ Ok ( k) => k,
271+ Err ( e) => {
272+ tracing:: warn!(
273+ error = ?e,
274+ publish_keypair_path = config. publish_keypair_path. display( ) . to_string( ) ,
275+ "Reading publish keypair returned an error. " ,
276+ ) ;
277+ bail ! ( "Reading publish keypair returned an error. " ) ;
278+ }
279+ } ;
280+
281+ let signing_key = SigningKey :: from_keypair_bytes ( & publish_keypair. to_bytes ( ) )
282+ . context ( "Failed to create signing key from keypair" ) ?;
264283 let mut publish_interval = tokio:: time:: interval ( config. publish_interval_duration ) ;
265284
266285 loop {
0 commit comments