pub struct AddressCache<D: AddressCacheDatabase> { /* private fields */ }
Expand description

Holds all addresses and associated transactions. We need a database with some basic methods, to store all data

Implementations§

source§

impl<D: AddressCacheDatabase> AddressCache<D>

source

pub fn block_process( &mut self, block: &Block, height: u32 ) -> Vec<(Transaction, TxOut)>

Iterates through a block, finds transactions destined to ourselves. Returns all transactions we found.

source

pub fn get_cached_addresses(&self) -> Vec<ScriptBuf>

source

pub fn bump_height(&self, height: u32)

source

pub fn get_cache_height(&self) -> u32

source

pub fn new(database: D) -> AddressCache<D>

source

pub fn get_address_utxos( &self, script_hash: &Hash ) -> Option<Vec<(TxOut, OutPoint)>>

source

pub fn get_transaction(&self, txid: &Txid) -> Option<CachedTransaction>

source

pub fn get_address_history( &self, script_hash: &Hash ) -> Option<Vec<CachedTransaction>>

Returns all transactions this address has, both input and outputs

source

pub fn get_address_balance(&self, script_hash: &Hash) -> u64

Returns the balance of this address, debts (spends) are taken in account

source

pub fn get_merkle_proof(&self, txid: &Txid) -> Option<(Vec<String>, u32)>

Returns the Merkle Proof for a given address

source

pub fn get_position(&self, txid: &Txid) -> Option<u32>

source

pub fn get_height(&self, txid: &Txid) -> Option<u32>

source

pub fn get_cached_transaction(&self, txid: &Txid) -> Option<String>

source

pub fn cache_address(&mut self, script_pk: ScriptBuf)

Adds a new address to track, should be called at wallet setup and every once in a while to cache new addresses, as we use the first ones. Only requires a script to cache.

source

pub fn setup(&self) -> Result<(), WatchOnlyError<D::Error>>

Setup is the first command that should be executed. In a new cache. It sets our wallet’s state, like the height we should start scanning and the wallet’s descriptor.

source

pub fn is_cached(&self, desc: &String) -> Result<bool, WatchOnlyError<D::Error>>

Tells whether or not a descriptor is already cached

source

pub fn is_address_cached(&self, script_hash: &Hash) -> bool

Tells wheter an address is already cached

source

pub fn push_descriptor( &self, descriptor: &str ) -> Result<(), WatchOnlyError<D::Error>>

source

pub fn find_unconfirmed( &self ) -> Result<Vec<Transaction>, WatchOnlyError<D::Error>>

source

pub fn cache_mempool_transaction( &mut self, transaction: &Transaction ) -> Vec<TxOut>

source

pub fn cache_transaction( &mut self, transaction: &Transaction, height: u32, value: u64, merkle_block: MerkleProof, position: u32, index: usize, is_spend: bool, hash: Hash )

Caches a new transaction. This method may be called for addresses we don’t follow yet, this automatically makes we follow this address.

Auto Trait Implementations§

§

impl<D> RefUnwindSafe for AddressCache<D>where D: RefUnwindSafe,

§

impl<D> Send for AddressCache<D>where D: Send,

§

impl<D> Sync for AddressCache<D>where D: Sync,

§

impl<D> Unpin for AddressCache<D>where D: Unpin,

§

impl<D> UnwindSafe for AddressCache<D>where D: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.