Allow import of Prysm keystores (#1535)

## Issue Addressed

- Resolves #1361

## Proposed Changes

Loosens the constraints imposed by EIP-2335 so we can import keys from Prysm.

## Additional Info

NA
This commit is contained in:
Paul Hauner
2020-08-18 06:28:20 +00:00
parent 8311074d68
commit 46dd530476
6 changed files with 78 additions and 13 deletions

View File

@@ -24,10 +24,14 @@ use serde_repr::*;
pub struct JsonKeystore {
pub crypto: Crypto,
pub uuid: Uuid,
pub path: String,
/// EIP-2335 does not declare this field as optional, but Prysm is omitting it so we must
/// support it.
pub path: Option<String>,
pub pubkey: String,
pub version: Version,
pub description: Option<String>,
/// Not part of EIP-2335, but `ethdo` and Prysm have adopted it anyway so we must support it.
pub name: Option<String>,
}
/// Version for `JsonKeystore`.

View File

@@ -172,10 +172,11 @@ impl Keystore {
},
},
uuid,
path,
path: Some(path),
pubkey: keypair.pk.to_hex_string()[2..].to_string(),
version: Version::four(),
description: None,
name: None,
},
})
}
@@ -218,8 +219,8 @@ impl Keystore {
/// Returns the path for the keystore.
///
/// Note: the path is not validated, it is simply whatever string the keystore provided.
pub fn path(&self) -> &str {
&self.json.path
pub fn path(&self) -> Option<String> {
self.json.path.clone()
}
/// Returns the pubkey for the keystore.