pub struct DerivationStandard<'a, 'b> {
pub base_path: &'a str,
pub starts_with: &'b str,
}Expand description
A derivation standard encapsulates the base derivation path used for key derivation and the expected address prefix that results from using that standard.
For instance, legacy addresses use the base path "m/44'/0'/0'/0/" and expect addresses starting with "1",
whereas native SegWit addresses use "m/84'/0'/0'/0/" with addresses beginning with "bc1q".
§Examples
use bit_digger::matcher::DerivationStandard;
let standard = DerivationStandard::new("m/44'/0'/0'/0/", "1");
assert_eq!(standard.base_path, "m/44'/0'/0'/0/");
assert_eq!(standard.starts_with, "1");Fields§
§base_path: &'a strThe base derivation path used to generate keys. Must have an ending back slash, i.e.
let valid_base_path = "m/44'/0'/0'/0/";starts_with: &'b strThe expected starting string/prefix for addresses generated with this standard.
Implementations§
Source§impl DerivationStandard<'_, '_>
impl DerivationStandard<'_, '_>
Sourcepub fn new<'a, 'b>(
base_path: &'a str,
starts_with: &'b str,
) -> DerivationStandard<'a, 'b>
pub fn new<'a, 'b>( base_path: &'a str, starts_with: &'b str, ) -> DerivationStandard<'a, 'b>
Returns a derivation standard with the given base path and expected address prefix.
§Examples
use bit_digger::matcher::DerivationStandard;
let standard = DerivationStandard::new("m/44'/0'/0'/0/", "1");Sourcepub fn from_address(address: &str) -> Option<&DerivationStandard<'_, '_>>
pub fn from_address(address: &str) -> Option<&DerivationStandard<'_, '_>>
Returns a reference to derivation standard if the address starts with a supported prefix.
§Examples
use bit_digger::matcher::DerivationStandard;
let standard = DerivationStandard::from_address("1BvB...");
assert_eq!(standard.unwrap().base_path, "m/44'/0'/0'/0/");Sourcepub fn into_address(
&self,
path: &DerivationPath,
xpriv: &Xpriv,
) -> Result<String, MatcherError>
pub fn into_address( &self, path: &DerivationPath, xpriv: &Xpriv, ) -> Result<String, MatcherError>
Sourcepub fn from_prefix(prefix: &str) -> Option<&DerivationStandard<'_, '_>>
pub fn from_prefix(prefix: &str) -> Option<&DerivationStandard<'_, '_>>
Returns a derivation standard if the address starts with a supported prefix.
Sourcepub fn get_supported_standards() -> &'static [DerivationStandard<'static, 'static>]
pub fn get_supported_standards() -> &'static [DerivationStandard<'static, 'static>]
Returns a slice of supported derivation standards.
Trait Implementations§
Source§impl<'a, 'b> Clone for DerivationStandard<'a, 'b>
impl<'a, 'b> Clone for DerivationStandard<'a, 'b>
Source§fn clone(&self) -> DerivationStandard<'a, 'b>
fn clone(&self) -> DerivationStandard<'a, 'b>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more