Skip to main content

LabelManager

Struct LabelManager 

Source
pub struct LabelManager { /* private fields */ }
Expand description

Manages labeled Silent Payment addresses with O(1) per-output lookup.

BIP 352 labels allow a receiver to generate multiple addresses from a single scan/spend key pair. Each label index m produces a distinct address with a deterministic tweak.

Internally stores HashMap<PublicKey, (Scalar, u32)> where:

  • Key: label_scalar * G (the label public key)
  • Value: (label_scalar, label_index_m)

Implementations§

Source§

impl LabelManager

Source

pub fn new() -> LabelManager

Create an empty label manager.

Source

pub fn add_label( &mut self, scan_secret: &ScanSecretKey, _spend_pubkey: &SpendPublicKey, m: u32, secp: &Secp256k1<All>, ) -> Result<(), CryptoError>

Register a label index m for scanning.

Computes the label tweak scalar via BIP0352/Label(b_scan || m), then derives the label public key (label_scalar * G) and stores it for O(1) lookup during output scanning.

§Errors

Returns CryptoError if the label tweak produces an invalid secret key (computationally unreachable).

Source

pub fn contains(&self, m: u32) -> bool

Check if a label index m has been registered.

Source

pub fn len(&self) -> usize

Number of registered labels.

Source

pub fn is_empty(&self) -> bool

Whether the manager has no registered labels.

Source

pub fn to_btree(&self) -> BTreeMap<PublicKey, (Scalar, u32)>

Convert to BTreeMap for bdk-sp consumption.

This is an O(n log n) operation but only happens once per scan_transaction call, not per output.

Trait Implementations§

Source§

impl Clone for LabelManager

Source§

fn clone(&self) -> LabelManager

Returns a duplicate 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 Debug for LabelManager

Source§

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

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

impl Default for LabelManager

Source§

fn default() -> LabelManager

Returns the “default value” for a type. Read more

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.