pub fn key_recover(private_key: &PrivateKey, testnet: bool) -> Result<ExtendedKey, SignerError> {
    let secret_key = libsecp256k1::SecretKey::parse_slice(&private_key.0)?;
    let public_key = libsecp256k1::PublicKey::from_secret_key(&secret_key);
    let mut address = Address::new_secp256k1(&public_key.serialize())?;

    if testnet {
        address.set_network(Network::Testnet);
    } else {
        address.set_network(Network::Mainnet);
    }

    Ok(ExtendedKey {
        private_key: PrivateKey(secret_key.serialize()),
        public_key: PublicKey::SECP256K1PublicKey(public_key),
        address: address.to_string(),
    })
}
/// Get extended key from private key
///
/// # Arguments
///
/// * `private_key` - A `PrivateKey`
/// * `testnet` - specify the network, `true` if testnet else `false` for mainnet
///
Get extended key from private key
Get extended key from private key
pub fn key_recover(private_key: &PrivateKey, testnet: bool) -> Result<ExtendedKey, SignerError> {
    let secret_key = libsecp256k1::SecretKey::parse_slice(&private_key.0)?;
    let public_key = libsecp256k1::PublicKey::from_secret_key(&secret_key);
    let mut address = Address::new_secp256k1(&public_key.serialize())?;
    if testnet {
        address.set_network(Network::Testnet);
    } else {
        address.set_network(Network::Mainnet);
    }
    Ok(ExtendedKey {
        private_key: PrivateKey(secret_key.serialize()),
        public_key: PublicKey::SECP256K1PublicKey(public_key),
        address: address.to_string(),
    })
}
pub fn key_recover ( private_key : & PrivateKey , testnet : bool ) -> Result < ExtendedKey , SignerError > { let secret_key = libsecp256k1 :: SecretKey :: parse_slice ( & private_key . 0 ) ? ; let public_key = libsecp256k1 :: PublicKey :: from_secret_key ( & secret_key ) ; let mut address = Address :: new_secp256k1 ( & public_key . serialize ( ) ) ? ; if testnet { address . set_network ( Network :: Testnet ) ; } else { address . set_network ( Network :: Mainnet ) ; } Ok ( ExtendedKey { private_key : PrivateKey ( secret_key . serialize ( ) ) , public_key : PublicKey :: SECP256K1PublicKey ( public_key ) , address : address . to_string ( ) , } ) }
Get extended key from private key
Get extended key from private key
private_key
&PrivateKey
testnet
bool
private_key
&PrivateKey
testnet
bool