Skip to main content

Descriptor

Struct Descriptor 

Source
pub struct Descriptor {
    pub n: u8,
    pub path_decl: PathDecl,
    pub use_site_path: UseSitePath,
    pub tree: Node,
    pub tlv: TlvSection,
}
Expand description

Top-level descriptor parsed/built from a v0.30 wire payload.

Each field corresponds to a spec section: Header (§3.2), origin PathDecl (§3.3), use-site UseSitePath (§3.4), descriptor tree (§3.5–3.6), and trailing tlv section (§3.7).

Fields§

§n: u8

Number of placeholders (1-indexed key universe size).

§path_decl: PathDecl

Origin path declaration (single or per-@N divergent).

§use_site_path: UseSitePath

Use-site (post-key) path applied to every key by default.

§tree: Node

Descriptor tree root node.

§tlv: TlvSection

Trailing TLV section (overrides, fingerprints, etc.).

Implementations§

Source§

impl Descriptor

Source

pub fn derive_address( &self, chain: u32, index: u32, network: Network, ) -> Result<Address<NetworkUnchecked>, Error>

Derive the address at (chain, index) for this descriptor on network.

chain selects the use-site multipath alternative (e.g. 0 = receive, 1 = change for the standard <0;1>/* form). index is the trailing wildcard child number.

Returns an Address<NetworkUnchecked>; callers can .assume_checked() (when they trust the network parameter) or .require_network(network) to lock it down.

§Errors
Source§

impl Descriptor

Source

pub fn key_index_width(&self) -> u8

Bit width for placeholder-index encoding: ⌈log₂(n)⌉ per SPEC v0.30 §7.

Index range is 0..n. The NUMS H-point is signalled by an explicit is_nums bit on Body::Tr (SPEC §7), not by a reserved sentinel. MUST stay in lockstep with decode::decode_payload’s independent computation; a stale formula would silently desync the bitstream.

Source

pub fn is_wallet_policy(&self) -> bool

Returns true iff this descriptor is in wallet-policy mode per SPEC §3.3: the Pubkeys TLV is present and contains at least one entry. Template-only mode (no Pubkeys TLV at all, or Pubkeys = Some(vec![]) after sparse-decode) returns false.

The check is a post-TLV-decode predicate; mode dispatch never reads a header bit.

Trait Implementations§

Source§

impl Clone for Descriptor

Source§

fn clone(&self) -> Descriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Descriptor

Source§

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

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

impl PartialEq for Descriptor

Source§

fn eq(&self, other: &Descriptor) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Eq for Descriptor

Source§

impl StructuralPartialEq for Descriptor

Auto Trait Implementations§

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.