Skip to main content

KeyCard

Struct KeyCard 

Source
#[non_exhaustive]
pub struct KeyCard { pub policy_id_stubs: Vec<[u8; 4]>, pub origin_fingerprint: Option<Fingerprint>, pub origin_path: DerivationPath, pub xpub: Xpub, }
Expand description

In-memory representation of one decoded MK card.

Per closure Q-8, origin_fingerprint is Option<Fingerprint>: a card encoded with the bytecode-header fingerprint flag unset (privacy-preserving mode) reconstructs to a KeyCard with origin_fingerprint = None.

#[non_exhaustive] so future versions can add fields without breaking external constructors.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§policy_id_stubs: Vec<[u8; 4]>

Policy ID stubs declaring which MD-encoded policy template(s) this xpub is intended to serve. Each stub is the top 4 bytes of the policy’s SHA-256(canonical_bytecode). The vector is guaranteed non-empty after a successful decode (the decoder rejects count == 0 with Error::InvalidPolicyIdStubCount).

§origin_fingerprint: Option<Fingerprint>

Master-key fingerprint identifying the seed from which xpub was derived. Verbatim from BIP 380 origin notation [fp/...]. Optional per closure Q-8: encoders MAY omit (set bytecode-header bit 2 = 0) for the privacy-preserving mode.

§origin_path: DerivationPath

Derivation path from master to xpub. Encoded on the wire either via a 1-byte standard-path indicator (BIP 44/49/84/86/ 48-segwit/48-nested/87 + testnet variants) or via the explicit 0xFE escape hatch with LEB128 components.

§xpub: Xpub

The BIP 32 extended public key. The wire format carries a 73-byte compact form (per closure Q-7); the in-memory Xpub is reconstructed at decode time using the locked rule:

depth        := component_count(origin_path)
child_number := last_component(origin_path)

Implementations§

Source§

impl KeyCard

Source

pub fn new( policy_id_stubs: Vec<[u8; 4]>, origin_fingerprint: Option<Fingerprint>, origin_path: DerivationPath, xpub: Xpub, ) -> Self

Construct a KeyCard from its four owned fields.

KeyCard is #[non_exhaustive] so that future versions can add fields without breaking external callers; the constructor stays stable across additions because new fields land with Default-compatible values or new constructors.

§Field invariants enforced at encode time

KeyCard::new is intentionally permissive — field-level validation lives in crate::encode / crate::bytecode::encode_bytecode. In particular:

Callers that want a fail-fast constructor should validate these invariants before calling new, or simply rely on the encoder’s rejection.

Trait Implementations§

Source§

impl Clone for KeyCard

Source§

fn clone(&self) -> KeyCard

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 KeyCard

Source§

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

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

impl PartialEq for KeyCard

Source§

fn eq(&self, other: &KeyCard) -> 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 KeyCard

Source§

impl StructuralPartialEq for KeyCard

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.