pub fn get_public_key(hd_path: BIP32Path) -> Result<PublicKey, NEARLedgerError>
Expand description

Gets PublicKey from the Ledger on the given hd_path

§Inputs

  • hd_path - seed phrase hd path slip10::BIP32Path for which PublicKey to look

§Returns

  • A Result whose Ok value is an ed25519_dalek::PublicKey and whose Err value is a NEARLedgerError containing an error which occurred.

§Examples

use near_ledger::get_public_key;
use slip10::BIP32Path;
use std::str::FromStr;

let hd_path = BIP32Path::from_str("44'/397'/0'/0'/1'").unwrap();
let public_key = get_public_key(hd_path).unwrap();
println!("{:#?}", public_key);

§Trick

To convert the answer into near_crypto::PublicKey do:

let public_key = near_crypto::PublicKey::ED25519(
    near_crypto::ED25519PublicKey::from(
        public_key.to_bytes(),
    )
);