pub trait DerivationStandard: Eq + Clone {
// Required methods
fn deduce(derivation: &DerivationPath) -> Option<Self>
where Self: Sized;
fn purpose(&self) -> Option<HardenedIndex>;
fn account_depth(&self) -> Option<u8>;
fn coin_type_depth(&self) -> Option<u8>;
fn is_account_last_hardened(&self) -> Option<bool>;
fn is_testnet(
&self,
path: &DerivationPath,
) -> Result<bool, Option<DerivationIndex>>;
fn account_template_string(&self, testnet: bool) -> String;
fn to_origin_derivation(
&self,
testnet: bool,
) -> DerivationPath<HardenedIndex>;
fn to_account_derivation(
&self,
account_index: HardenedIndex,
testnet: bool,
) -> DerivationPath<HardenedIndex>;
fn to_key_derivation(
&self,
account_index: HardenedIndex,
testnet: bool,
keychain: NormalIndex,
index: NormalIndex,
) -> DerivationPath;
// Provided methods
fn extract_coin_type(
&self,
path: &DerivationPath,
) -> Result<HardenedIndex, Option<NormalIndex>> { ... }
fn extract_account_index(
&self,
path: &DerivationPath,
) -> Result<HardenedIndex, Option<NormalIndex>> { ... }
}Expand description
Methods for derivation standard enumeration types.
Required Methods§
Sourcefn deduce(derivation: &DerivationPath) -> Option<Self>where
Self: Sized,
fn deduce(derivation: &DerivationPath) -> Option<Self>where
Self: Sized,
Deduces derivation standard used by the provided derivation path, if possible.
Sourcefn purpose(&self) -> Option<HardenedIndex>
fn purpose(&self) -> Option<HardenedIndex>
Get hardened index matching BIP-43 purpose value, if any.
Sourcefn account_depth(&self) -> Option<u8>
fn account_depth(&self) -> Option<u8>
Depth of the account extended public key according to the given standard.
Returns None if the standard does not provide information on
account-level xpubs.
Sourcefn coin_type_depth(&self) -> Option<u8>
fn coin_type_depth(&self) -> Option<u8>
Depth of the derivation path defining coin_type key, i.e. the used
blockchain.
Returns None if the standard does not provide information on
blockchain/coin type.
Sourcefn is_account_last_hardened(&self) -> Option<bool>
fn is_account_last_hardened(&self) -> Option<bool>
Returns information whether the account xpub in this standard is the
last hardened derivation path step, or there might be more hardened
steps (like script_type in BIP-48).
Returns None if the standard does not provide information on
account-level xpubs.
Sourcefn is_testnet(
&self,
path: &DerivationPath,
) -> Result<bool, Option<DerivationIndex>>
fn is_testnet( &self, path: &DerivationPath, ) -> Result<bool, Option<DerivationIndex>>
Checks which bitcoin network corresponds to a given derivation path according to the used standard requirements.
Sourcefn account_template_string(&self, testnet: bool) -> String
fn account_template_string(&self, testnet: bool) -> String
Returns string representation of the template derivation path for an
account-level keys. Account key is represented by * wildcard fragment.
Sourcefn to_origin_derivation(&self, testnet: bool) -> DerivationPath<HardenedIndex>
fn to_origin_derivation(&self, testnet: bool) -> DerivationPath<HardenedIndex>
Construct derivation path for the account xpub.
Sourcefn to_account_derivation(
&self,
account_index: HardenedIndex,
testnet: bool,
) -> DerivationPath<HardenedIndex>
fn to_account_derivation( &self, account_index: HardenedIndex, testnet: bool, ) -> DerivationPath<HardenedIndex>
Construct derivation path up to the provided account index segment.
Sourcefn to_key_derivation(
&self,
account_index: HardenedIndex,
testnet: bool,
keychain: NormalIndex,
index: NormalIndex,
) -> DerivationPath
fn to_key_derivation( &self, account_index: HardenedIndex, testnet: bool, keychain: NormalIndex, index: NormalIndex, ) -> DerivationPath
Construct full derivation path including address index and case (main, change etc).
Provided Methods§
Sourcefn extract_coin_type(
&self,
path: &DerivationPath,
) -> Result<HardenedIndex, Option<NormalIndex>>
fn extract_coin_type( &self, path: &DerivationPath, ) -> Result<HardenedIndex, Option<NormalIndex>>
Extracts hardened index from a derivation path position defining coin type information (used blockchain), if present.
§Returns
Err(None)error if the path doesn’t contain any coin index information;Err(NormalIndex)error if the coin type in the derivation path was an unhardened index.Ok(HardenedIndex)with the coin type index otherwise.
Sourcefn extract_account_index(
&self,
path: &DerivationPath,
) -> Result<HardenedIndex, Option<NormalIndex>>
fn extract_account_index( &self, path: &DerivationPath, ) -> Result<HardenedIndex, Option<NormalIndex>>
Extracts hardened index from a derivation path position defining account number, if present.
§Returns
Err(None)error if the path doesn’t contain any account number information;Err(NormalIndex)error if the account number in the derivation path was an unhardened index.Ok(HardenedIndex)with the account number otherwise.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.