19
19
reqwest:: Client ,
20
20
serde:: Deserialize ,
21
21
std:: {
22
+ path:: PathBuf ,
22
23
sync:: Arc ,
23
24
time:: Duration ,
24
25
} ,
@@ -48,7 +49,7 @@ pub struct Config {
48
49
pub relayer_urls : Vec < Url > ,
49
50
pub publisher_id : u32 ,
50
51
pub authorization_token : String ,
51
- publisher_secret_key : PublisherSecretKey ,
52
+ pub publish_keypair_path : PathBuf ,
52
53
#[ serde( with = "humantime_serde" , default = "default_publish_interval" ) ]
53
54
pub publish_interval_duration : Duration ,
54
55
}
@@ -173,7 +174,10 @@ mod lazer_exporter {
173
174
} ,
174
175
state:: local:: LocalStore ,
175
176
} ,
176
- anyhow:: bail,
177
+ anyhow:: {
178
+ Context ,
179
+ bail,
180
+ } ,
177
181
ed25519_dalek:: {
178
182
Signer ,
179
183
SigningKey ,
@@ -198,6 +202,7 @@ mod lazer_exporter {
198
202
lazer_transaction:: Payload ,
199
203
} ,
200
204
} ,
205
+ solana_sdk:: signer:: keypair,
201
206
std:: {
202
207
collections:: HashMap ,
203
208
sync:: Arc ,
@@ -260,7 +265,21 @@ mod lazer_exporter {
260
265
stream_map. insert ( config. relayer_urls [ i] . clone ( ) , receiver) ;
261
266
}
262
267
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" ) ?;
264
283
let mut publish_interval = tokio:: time:: interval ( config. publish_interval_duration ) ;
265
284
266
285
loop {
0 commit comments