File tree 2 files changed +25
-0
lines changed 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ //! Key management: sr25519 account key used for signing blob submission
2
+ //! transactions.
3
+
4
+ use subxt_signer:: sr25519:: { Seed , Keypair } ;
5
+ use std:: path:: Path ;
6
+
7
+ /// Load a key from the provided file path.
8
+ ///
9
+ /// The file should contain a hex-encoded 32-byte seed used to generate
10
+ /// the underlying schnorrkel private key.
11
+ pub fn load_key_from_file < P : AsRef < Path > > ( path : P ) -> anyhow:: Result < Keypair > {
12
+ let raw = hex:: decode ( std:: fs:: read ( path) ?) ?;
13
+ let mut seed: Seed = Seed :: default ( ) ;
14
+ if raw. len ( ) <= seed. len ( ) {
15
+ anyhow:: bail!( "Keyfile length invalid" )
16
+ }
17
+ seed. copy_from_slice ( & raw [ ..] ) ;
18
+ Ok ( Keypair :: from_seed ( seed) ?)
19
+ }
20
+
21
+ /// The default dev key.
22
+ pub fn alice ( ) -> Keypair {
23
+ subxt_signer:: sr25519:: dev:: alice ( )
24
+ }
Original file line number Diff line number Diff line change 1
1
mod adapters;
2
2
mod cli;
3
3
mod cmd;
4
+ mod key;
4
5
mod sugondat_rpc;
5
6
6
7
#[ tokio:: main]
You can’t perform that action at this time.
0 commit comments