diff --git a/Cargo.lock b/Cargo.lock index 5deb998..aa9f869 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,6 +50,7 @@ dependencies = [ "sp-consensus-pow", "sp-core", "sp-inherents", + "sp-keyring", "sp-runtime", "sp-timestamp", "sp-transaction-pool", diff --git a/Cargo.toml b/Cargo.toml index ae994f0..abc7643 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ sp-core = { branch = "release-polkadot-v1.5.0", default-features = false, git = sp-genesis-builder = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" } sp-inherents = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" } sp-io = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" } +sp-keyring = { branch = "release-polkadot-v1.5.0", git = "https://github.com/paritytech/polkadot-sdk" } sp-keystore = { branch = "release-polkadot-v1.5.0", git = "https://github.com/paritytech/polkadot-sdk" } sp-offchain = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" } sp-runtime = { branch = "release-polkadot-v1.5.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk" } diff --git a/node/Cargo.toml b/node/Cargo.toml index e4f759b..a790acf 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -45,6 +45,7 @@ sp-consensus = { workspace = true } sp-consensus-pow = { workspace = true } sp-core = { workspace = true } sp-inherents = { workspace = true } +sp-keyring = { workspace = true } sp-runtime = { workspace = true } sp-timestamp = { workspace = true } sp-transaction-pool = { workspace = true } diff --git a/node/src/cli.rs b/node/src/cli.rs index ff840bc..4e1ac61 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -47,12 +47,12 @@ pub struct AcademyPowCli { } impl AcademyPowCli { - pub fn public_key_bytes(&self) -> [u8; 32] { + pub fn public_key_bytes(&self, keyring: Option) -> [u8; 32] { match &self.mining_account_id { Some(account_id) => *account_id.as_ref(), None => match self.mining_public_key { Some(public_key) => public_key.0, - None => [0u8; 32], + None => keyring.map(|k| k.to_raw_public()).unwrap_or([0u8; 32]), }, } } diff --git a/node/src/command.rs b/node/src/command.rs index 3a294f2..4f92b39 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -147,7 +147,7 @@ pub fn run() -> sc_cli::Result<()> { } None => { // Get the mining account from the cli - let bytes: [u8; 32] = cli.pow.public_key_bytes(); + let bytes: [u8; 32] = cli.pow.public_key_bytes(cli.run.get_keyring()); let sr25519_public_key = Public(bytes); let runner = cli.create_runner(&cli.run)?;