Struct floresta_watch_only::AddressCache
source · 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>
impl<D: AddressCacheDatabase> AddressCache<D>
sourcepub fn block_process(
&mut self,
block: &Block,
height: u32
) -> Vec<(Transaction, TxOut)>
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.
pub fn get_cached_addresses(&self) -> Vec<ScriptBuf>
pub fn bump_height(&self, height: u32)
pub fn get_cache_height(&self) -> u32
pub fn new(database: D) -> AddressCache<D>
pub fn get_address_utxos( &self, script_hash: &Hash ) -> Option<Vec<(TxOut, OutPoint)>>
pub fn get_transaction(&self, txid: &Txid) -> Option<CachedTransaction>
sourcepub fn get_address_history(
&self,
script_hash: &Hash
) -> Option<Vec<CachedTransaction>>
pub fn get_address_history( &self, script_hash: &Hash ) -> Option<Vec<CachedTransaction>>
Returns all transactions this address has, both input and outputs
sourcepub fn get_address_balance(&self, script_hash: &Hash) -> u64
pub fn get_address_balance(&self, script_hash: &Hash) -> u64
Returns the balance of this address, debts (spends) are taken in account
sourcepub fn get_merkle_proof(&self, txid: &Txid) -> Option<(Vec<String>, u32)>
pub fn get_merkle_proof(&self, txid: &Txid) -> Option<(Vec<String>, u32)>
Returns the Merkle Proof for a given address
pub fn get_position(&self, txid: &Txid) -> Option<u32>
pub fn get_height(&self, txid: &Txid) -> Option<u32>
pub fn get_cached_transaction(&self, txid: &Txid) -> Option<String>
sourcepub fn cache_address(&mut self, script_pk: ScriptBuf)
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.
sourcepub fn setup(&self) -> Result<(), WatchOnlyError<D::Error>>
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.
sourcepub fn is_cached(&self, desc: &String) -> Result<bool, WatchOnlyError<D::Error>>
pub fn is_cached(&self, desc: &String) -> Result<bool, WatchOnlyError<D::Error>>
Tells whether or not a descriptor is already cached
sourcepub fn is_address_cached(&self, script_hash: &Hash) -> bool
pub fn is_address_cached(&self, script_hash: &Hash) -> bool
Tells wheter an address is already cached
pub fn push_descriptor( &self, descriptor: &str ) -> Result<(), WatchOnlyError<D::Error>>
pub fn find_unconfirmed( &self ) -> Result<Vec<Transaction>, WatchOnlyError<D::Error>>
pub fn cache_mempool_transaction( &mut self, transaction: &Transaction ) -> Vec<TxOut>
sourcepub fn cache_transaction(
&mut self,
transaction: &Transaction,
height: u32,
value: u64,
merkle_block: MerkleProof,
position: u32,
index: usize,
is_spend: bool,
hash: Hash
)
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.