Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix the --key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed Aug 1, 2018
1 parent f1c682a commit 00c925c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
15 changes: 13 additions & 2 deletions substrate/keystore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,19 @@ impl Store {
// TODO: Remove this
pub fn generate_from_seed(&mut self, seed: &str) -> Result<Pair> {
let mut s: [u8; 32] = [' ' as u8; 32];
let len = ::std::cmp::min(32, seed.len());
&mut s[..len].copy_from_slice(&seed.as_bytes()[..len]);

let was_hex = if seed.len() == 66 && &seed[0..2] == "0x" {
if let Ok(d) = hex::decode(&seed[2..]) {
s.copy_from_slice(&d);
true
} else { false }
} else { false };

if !was_hex {
let len = ::std::cmp::min(32, seed.len());
&mut s[..len].copy_from_slice(&seed.as_bytes()[..len]);
}

let pair = Pair::from_seed(&s);
self.additional.insert(pair.public(), s);
Ok(pair)
Expand Down
14 changes: 7 additions & 7 deletions substrate/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<Components> Service<Components>
chain,
author,
rpc_config.clone(),
)
)
};
(
maybe_start_server(config.rpc_http, |address| rpc::start_http(address, handler()))?,
Expand All @@ -227,12 +227,12 @@ impl<Components> Service<Components>
url: url,
on_connect: Box::new(move || {
telemetry!("system.connected";
"name" => name.clone(),
"implementation" => impl_name.clone(),
"version" => version.clone(),
"config" => "",
"chain" => chain_name.clone(),
);
"name" => name.clone(),
"implementation" => impl_name.clone(),
"version" => version.clone(),
"config" => "",
"chain" => chain_name.clone(),
);
}),
}))
},
Expand Down

0 comments on commit 00c925c

Please sign in to comment.