Generic keystore (#3008)

* Add KeyTypeId.

* Implement clone for sr25519::Pair.

* Extend Pair with to_raw_vec.

* Implement TypedKey for Signature and Pair.

* Add trait Public.

* Make keystore generic.

* Fixup clone.

* Fix tests.

* Update service.

* Fix imports.

* Fix build.

* Fix babe build.

* Fix subkey build.

* Make authority setup generic.

* Update node-template.

* Fix build.

* Remove unsafe code.

* Fix tests.
This commit is contained in:
David Craven
2019-07-04 13:14:55 +02:00
committed by GitHub
parent 336053f7ae
commit 51e345c901
15 changed files with 279 additions and 122 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ use std::{str::FromStr, io::{stdin, Read}};
use hex_literal::hex;
use clap::load_yaml;
use bip39::{Mnemonic, Language, MnemonicType};
use substrate_primitives::{ed25519, sr25519, hexdisplay::HexDisplay, Pair, crypto::Ss58Codec, blake2_256};
use substrate_primitives::{ed25519, sr25519, hexdisplay::HexDisplay, Pair, Public, crypto::Ss58Codec, blake2_256};
use parity_codec::{Encode, Decode, Compact};
use sr_primitives::generic::Era;
use node_primitives::{Balance, Index, Hash};
@@ -32,7 +32,7 @@ mod vanity;
trait Crypto {
type Pair: Pair<Public=Self::Public>;
type Public: Ss58Codec + AsRef<[u8]>;
type Public: Public + Ss58Codec + AsRef<[u8]> + std::hash::Hash;
fn pair_from_suri(suri: &str, password: Option<&str>) -> Self::Pair {
Self::Pair::from_string(suri, password).expect("Invalid phrase")
}