Struct DerivationStandard

Source
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 str

The 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 str

The expected starting string/prefix for addresses generated with this standard.

Implementations§

Source§

impl DerivationStandard<'_, '_>

Source

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");
Source

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/");
Source

pub fn into_address( &self, path: &DerivationPath, xpriv: &Xpriv, ) -> Result<String, MatcherError>

Converts the provided derivation path and extended private key into a Bitcoin address

§Errors

Returns a MatcherError if key derivation fails or if a public key cannot be properly compressed.

§Examples

See examples in Matcher::generate_addresses

Source

pub fn from_prefix(prefix: &str) -> Option<&DerivationStandard<'_, '_>>

Returns a derivation standard if the address starts with a supported prefix.

Source

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>

Source§

fn clone(&self) -> DerivationStandard<'a, 'b>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, 'b> Debug for DerivationStandard<'a, 'b>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, 'b> PartialEq for DerivationStandard<'a, 'b>

Source§

fn eq(&self, other: &DerivationStandard<'a, 'b>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> StructuralPartialEq for DerivationStandard<'a, 'b>

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for DerivationStandard<'a, 'b>

§

impl<'a, 'b> RefUnwindSafe for DerivationStandard<'a, 'b>

§

impl<'a, 'b> Send for DerivationStandard<'a, 'b>

§

impl<'a, 'b> Sync for DerivationStandard<'a, 'b>

§

impl<'a, 'b> Unpin for DerivationStandard<'a, 'b>

§

impl<'a, 'b> UnwindSafe for DerivationStandard<'a, 'b>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.