method added to construct keypair from raw bytes

This commit is contained in:
Bruce Leidl 2019-04-02 15:15:28 -04:00
parent e493e5180d
commit cf85d10055

View File

@ -50,6 +50,10 @@ impl KeyPair {
pub fn from_hex(hex: &str) -> Result<KeyPair> {
let bytes = hex::decode(hex)?;
KeyPair::from_bytes(&bytes)
}
pub fn from_bytes(bytes: &[u8]) -> Result<KeyPair> {
if bytes.len() != SEEDBYTES {
bail!("Hex encoded keypair has incorrect length");
}