Struct Wallet

Source
pub struct Wallet<K, D: Descriptor<K>, L2: Layer2 = NoLayer2> { /* private fields */ }

Implementations§

Source§

impl<K, D: Descriptor<K>> Wallet<K, D>

Source

pub fn new_layer1(descr: D, network: Network) -> Self

Source§

impl<K, D: Descriptor<K>, L2: Layer2> Wallet<K, D, L2>

Source

pub fn new_layer2( descr: D, l2_descr: L2::Descr, layer2: L2, network: Network, ) -> Self

Source

pub fn set_name(&mut self, name: String)

Source

pub fn with_descriptor<T, E>( &mut self, f: impl FnOnce(&mut D) -> Result<T, E>, ) -> Result<T, E>

Source

pub fn data_l2(&self) -> &L2::Data

Source

pub fn cache_l2(&self) -> &L2::Cache

Source

pub fn with_data<T, E>( &mut self, f: impl FnOnce(&mut WalletData<L2::Data>) -> Result<T, E>, ) -> Result<T, E>

Source

pub fn with_data_l2<T, E>( &mut self, f: impl FnOnce(&mut L2::Data) -> Result<T, E>, ) -> Result<T, E>

Source

pub fn with_cache_l2<T, E>( &mut self, f: impl FnOnce(&mut L2::Cache) -> Result<T, E>, ) -> Result<T, E>

Source

pub fn update<I: Indexer>(&mut self, indexer: &I) -> MayError<(), Vec<I::Error>>

Source

pub fn to_deriver(&self) -> D
where D: Clone, K: Clone,

Source

pub fn last_derivation_index( &self, keychain: impl Into<Keychain>, ) -> NormalIndex

Source

pub fn next_address( &mut self, keychain: impl Into<Keychain>, shift: bool, ) -> Address

Source

pub fn balance(&self) -> Sats

Source

pub fn transactions(&self) -> &BTreeMap<Txid, WalletTx>

Source

pub fn coins( &self, ) -> impl Iterator<Item = CoinRow<<L2::Cache as Layer2Cache>::Coin>> + '_

Source

pub fn address_coins( &self, ) -> HashMap<DerivedAddr, Vec<CoinRow<<L2::Cache as Layer2Cache>::Coin>>>

Source

pub fn address_balance(&self) -> impl Iterator<Item = WalletAddr> + '_

Source

pub fn history( &self, ) -> impl Iterator<Item = TxRow<<L2::Cache as Layer2Cache>::Tx>> + '_

Source

pub fn has_outpoint(&self, outpoint: Outpoint) -> bool

Source

pub fn is_unspent(&self, outpoint: Outpoint) -> bool

Source

pub fn outpoint_by( &self, outpoint: Outpoint, ) -> Result<(WalletUtxo, ScriptPubkey), NonWalletItem>

Source

pub fn txos(&self) -> impl Iterator<Item = WalletUtxo> + '_

Source

pub fn utxos(&self) -> impl Iterator<Item = WalletUtxo> + '_

Source

pub fn coinselect<'a>( &'a self, up_to: Sats, selector: impl Fn(&WalletUtxo) -> bool + 'a, ) -> impl Iterator<Item = Outpoint> + 'a

Source§

impl<K, D: Descriptor<K>, L2: Layer2> Wallet<K, D, L2>

Source

pub fn load<P>( provider: P, autosave: bool, ) -> Result<Wallet<K, D, L2>, PersistenceError>

Source

pub fn set_id(&mut self, id: &impl ToString)

Source

pub fn make_persistent<P>( &mut self, provider: P, autosave: bool, ) -> Result<bool, PersistenceError>

Source

pub fn store(&mut self) -> Result<(), PersistenceError>

Methods from Deref<Target = WalletDescr<K, D, L2::Descr>>§

Source

pub fn generator(&self) -> &D

Method borrowing WalletDescr::generator field.

Source

pub fn network(&self) -> Network

Method returning copy of WalletDescr::network field.

Source

pub fn layer2(&self) -> &L2

Method borrowing WalletDescr::layer2 field.

Source

pub fn _phantom(&self) -> &PhantomData<K>

Method borrowing WalletDescr::_phantom field.

Source

pub fn addresses(&self, keychain: impl Into<Keychain>) -> AddrIter<'_, K, D>

Trait Implementations§

Source§

impl<K, D: Descriptor<K>, L2: Layer2> CloneNoPersistence for Wallet<K, D, L2>

Source§

impl<K: Debug, D: Debug + Descriptor<K>, L2: Debug + Layer2> Debug for Wallet<K, D, L2>
where L2::Descr: Debug, L2::Data: Debug, L2::Cache: Debug,

Source§

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

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

impl<K, D: Descriptor<K>, L2: Layer2> Deref for Wallet<K, D, L2>

Source§

type Target = WalletDescr<K, D, <L2 as Layer2>::Descr>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<K, D: Descriptor<K>, L2: Layer2> PsbtConstructor for Wallet<K, D, L2>

Source§

type Key = K

Source§

type Descr = D

Source§

fn descriptor(&self) -> &D

Source§

fn utxo(&self, outpoint: Outpoint) -> Option<(Utxo, ScriptPubkey)>

Source§

fn network(&self) -> Network

Source§

fn next_derivation_index( &mut self, keychain: impl Into<Keychain>, shift: bool, ) -> NormalIndex

Source§

fn after_construct_psbt(&mut self, psbt: &Psbt, meta: &PsbtMeta)

A hook which is called by the default Self::construct_psbt before returning the newly constructed PSBT to the caller.
Source§

fn construct_psbt( &mut self, coins: impl IntoIterator<Item = Outpoint>, beneficiaries: impl IntoIterator<Item = Beneficiary>, params: TxParams, ) -> Result<(Psbt, PsbtMeta), ConstructionError>

Auto Trait Implementations§

§

impl<K, D, L2> Freeze for Wallet<K, D, L2>
where L2: Freeze, D: Freeze, <L2 as Layer2>::Descr: Freeze, <L2 as Layer2>::Data: Freeze, <L2 as Layer2>::Cache: Freeze,

§

impl<K, D, L2 = NoLayer2> !RefUnwindSafe for Wallet<K, D, L2>

§

impl<K, D, L2> Send for Wallet<K, D, L2>
where L2: Send, D: Send, <L2 as Layer2>::Descr: Send, <L2 as Layer2>::Data: Send, <L2 as Layer2>::Cache: Send, K: Send,

§

impl<K, D, L2> Sync for Wallet<K, D, L2>
where L2: Sync, D: Sync, <L2 as Layer2>::Descr: Sync, <L2 as Layer2>::Data: Sync, <L2 as Layer2>::Cache: Sync, K: Sync,

§

impl<K, D, L2> Unpin for Wallet<K, D, L2>
where L2: Unpin, D: Unpin, <L2 as Layer2>::Descr: Unpin, <L2 as Layer2>::Data: Unpin, <L2 as Layer2>::Cache: Unpin, K: Unpin,

§

impl<K, D, L2 = NoLayer2> !UnwindSafe for Wallet<K, D, L2>

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.