pub trait VersionResolver: Copy + Clone + PartialEq + Eq + PartialOrd + Ord + Hash + Debug {
    type Network;
    type Application;

    // Required method
    fn resolve(
        network: Self::Network,
        applicable_for: Self::Application,
        is_priv: bool
    ) -> KeyVersion;

    // Provided methods
    fn is_pub(_: &KeyVersion) -> Option<bool> { ... }
    fn is_prv(_: &KeyVersion) -> Option<bool> { ... }
    fn network(_: &KeyVersion) -> Option<Self::Network> { ... }
    fn application(_: &KeyVersion) -> Option<Self::Application> { ... }
    fn derivation_path(
        _: &KeyVersion,
        _: Option<ChildNumber>
    ) -> Option<DerivationPath> { ... }
    fn make_pub(_: &KeyVersion) -> Option<KeyVersion> { ... }
    fn make_prv(_: &KeyVersion) -> Option<KeyVersion> { ... }
}
Expand description

Trait which must be implemented by helpers which do construction, interpretation, verification and cross-conversion of extended public and private key version magic bytes from KeyVersion

Required Associated Types§

source

type Network

Type that defines recognized network options

source

type Application

Type that defines possible applications fro public and private keys (types of scriptPubkey descriptors in which they can be used)

Required Methods§

source

fn resolve( network: Self::Network, applicable_for: Self::Application, is_priv: bool ) -> KeyVersion

Constructor for KeyVersion with given network, application scope and key type (public or private)

Provided Methods§

source

fn is_pub(_: &KeyVersion) -> Option<bool>

Detects whether provided version corresponds to an extended public key. Returns None if the version is not recognized/unknown to the resolver.

source

fn is_prv(_: &KeyVersion) -> Option<bool>

Detects whether provided version corresponds to an extended private key. Returns None if the version is not recognized/unknown to the resolver.

source

fn network(_: &KeyVersion) -> Option<Self::Network>

Detects network used by the provided key version bytes. Returns None if the version is not recognized/unknown to the resolver.

source

fn application(_: &KeyVersion) -> Option<Self::Application>

Detects application scope defined by the provided key version bytes. Application scope is a types of scriptPubkey descriptors in which given extended public/private keys can be used. Returns None if the version is not recognized/unknown to the resolver.

source

fn derivation_path( _: &KeyVersion, _: Option<ChildNumber> ) -> Option<DerivationPath>

Returns BIP 32 derivation path for the provided key version. Returns None if the version is not recognized/unknown to the resolver.

source

fn make_pub(_: &KeyVersion) -> Option<KeyVersion>

Converts version into version corresponding to an extended public key. Returns None if the resolver does not know how to perform conversion.

source

fn make_prv(_: &KeyVersion) -> Option<KeyVersion>

Converts version into version corresponding to an extended private key. Returns None if the resolver does not know how to perform conversion.

Object Safety§

This trait is not object safe.

Implementors§