pub struct VtxoFilter<'a> {
pub expires_before: Option<BlockHeight>,
pub counterparty: bool,
pub exclude: HashSet<VtxoId>,
pub include: HashSet<VtxoId>,
/* private fields */
}Expand description
Filter vtxos based on criteria.
Builder pattern is used.
Matching semantics:
- Explicit
includeandexcludelists have the highest priority. - Remaining criteria (expiry, counterparty risk) are combined with OR: if any matches, the VTXO is kept.
Fields§
§expires_before: Option<BlockHeight>Include vtxos that expire before the given height.
counterparty: boolIf true, include vtxos that have counterparty risk.
exclude: HashSet<VtxoId>Exclude certain vtxos.
include: HashSet<VtxoId>Force include certain vtxos.
Implementations§
Source§impl<'a> VtxoFilter<'a>
impl<'a> VtxoFilter<'a>
Sourcepub fn new(wallet: &'a Wallet) -> VtxoFilter<'a>
pub fn new(wallet: &'a Wallet) -> VtxoFilter<'a>
Create a new VtxoFilter bound to a wallet context.
The wallet is used to evaluate properties such as counterparty risk. By default, the filter matches nothing until criteria are added.
Examples
use bark::vtxo::selection::{VtxoFilter, FilterVtxos};
use bitcoin_ext::BlockHeight;
let tip: BlockHeight = 1_000;
let filter = VtxoFilter::new(wallet)
.expires_before(tip + 144) // expiring within ~1 day
.counterparty(); // or with counterparty risk
let filtered = wallet.spendable_vtxos_with(&filter)?;Sourcepub fn expires_before(self, expires_before: BlockHeight) -> Self
pub fn expires_before(self, expires_before: BlockHeight) -> Self
Include vtxos that expire before the given height.
Examples
use bark::vtxo::selection::{VtxoFilter, FilterVtxos};
use bitcoin_ext::BlockHeight;
let h: BlockHeight = 10_000;
let filter = VtxoFilter::new(wallet)
.expires_before(h);
let filtered = wallet.spendable_vtxos_with(&filter)?;Sourcepub fn counterparty(self) -> Self
pub fn counterparty(self) -> Self
Include vtxos that have counterparty risk.
An arkoor vtxo is considered to have some counterparty risk if it’s (directly or not) based on round VTXOs that aren’t owned by the wallet.
Sourcepub fn exclude_many(self, exclude: impl IntoIterator<Item = VtxoId>) -> Self
pub fn exclude_many(self, exclude: impl IntoIterator<Item = VtxoId>) -> Self
Exclude the given vtxos.
Sourcepub fn include_many(self, include: impl IntoIterator<Item = VtxoId>) -> Self
pub fn include_many(self, include: impl IntoIterator<Item = VtxoId>) -> Self
Include the given vtxos.
Trait Implementations§
Source§impl FilterVtxos for VtxoFilter<'_>
impl FilterVtxos for VtxoFilter<'_>
Source§fn matches(&self, vtxo: &WalletVtxo) -> Result<bool>
fn matches(&self, vtxo: &WalletVtxo) -> Result<bool>
Check whether the VTXO mathes this filter
Source§fn filter_vtxos<V: Borrow<WalletVtxo>>(&self, vtxos: &mut Vec<V>) -> Result<()>
fn filter_vtxos<V: Borrow<WalletVtxo>>(&self, vtxos: &mut Vec<V>) -> Result<()>
Eliminate from the vector all non-matching VTXOs
Auto Trait Implementations§
impl<'a> Freeze for VtxoFilter<'a>
impl<'a> !RefUnwindSafe for VtxoFilter<'a>
impl<'a> Send for VtxoFilter<'a>
impl<'a> Sync for VtxoFilter<'a>
impl<'a> Unpin for VtxoFilter<'a>
impl<'a> !UnwindSafe for VtxoFilter<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request