pub trait InputSource {
type Error: Debug;
type AccountId: Copy + Debug + Eq + Hash;
type NoteRef: Copy + Debug + Eq + Ord;
// Required methods
fn get_spendable_note(
&self,
txid: &TxId,
protocol: ShieldedProtocol,
index: u32,
) -> Result<Option<ReceivedNote<Self::NoteRef, Note>>, Self::Error>;
fn select_spendable_notes(
&self,
account: Self::AccountId,
target_value: Zatoshis,
sources: &[ShieldedProtocol],
anchor_height: BlockHeight,
exclude: &[Self::NoteRef],
) -> Result<SpendableNotes<Self::NoteRef>, Self::Error>;
fn get_account_metadata(
&self,
account: Self::AccountId,
selector: &NoteFilter,
exclude: &[Self::NoteRef],
) -> Result<AccountMeta, Self::Error>;
// Provided methods
fn get_unspent_transparent_output(
&self,
_outpoint: &OutPoint,
) -> Result<Option<WalletTransparentOutput>, Self::Error> { ... }
fn get_spendable_transparent_outputs(
&self,
_address: &TransparentAddress,
_target_height: BlockHeight,
_min_confirmations: u32,
) -> Result<Vec<WalletTransparentOutput>, Self::Error> { ... }
}
Expand description
A trait representing the capability to query a data store for unspent transaction outputs belonging to a account.
Required Associated Types§
Sourcetype AccountId: Copy + Debug + Eq + Hash
type AccountId: Copy + Debug + Eq + Hash
Backend-specific account identifier.
An account identifier corresponds to at most a single unified spending key’s worth of spend authority, such that both received notes and change spendable by that spending authority will be interpreted as belonging to that account. This might be a database identifier type or a UUID.
Required Methods§
Sourcefn get_spendable_note(
&self,
txid: &TxId,
protocol: ShieldedProtocol,
index: u32,
) -> Result<Option<ReceivedNote<Self::NoteRef, Note>>, Self::Error>
fn get_spendable_note( &self, txid: &TxId, protocol: ShieldedProtocol, index: u32, ) -> Result<Option<ReceivedNote<Self::NoteRef, Note>>, Self::Error>
Fetches a spendable note by indexing into a transaction’s shielded outputs for the specified shielded protocol.
Returns Ok(None)
if the note is not known to belong to the wallet or if the note
is not spendable.
Sourcefn select_spendable_notes(
&self,
account: Self::AccountId,
target_value: Zatoshis,
sources: &[ShieldedProtocol],
anchor_height: BlockHeight,
exclude: &[Self::NoteRef],
) -> Result<SpendableNotes<Self::NoteRef>, Self::Error>
fn select_spendable_notes( &self, account: Self::AccountId, target_value: Zatoshis, sources: &[ShieldedProtocol], anchor_height: BlockHeight, exclude: &[Self::NoteRef], ) -> Result<SpendableNotes<Self::NoteRef>, Self::Error>
Returns a list of spendable notes sufficient to cover the specified target value, if possible. Only spendable notes corresponding to the specified shielded protocol will be included.
Sourcefn get_account_metadata(
&self,
account: Self::AccountId,
selector: &NoteFilter,
exclude: &[Self::NoteRef],
) -> Result<AccountMeta, Self::Error>
fn get_account_metadata( &self, account: Self::AccountId, selector: &NoteFilter, exclude: &[Self::NoteRef], ) -> Result<AccountMeta, Self::Error>
Returns metadata describing the structure of the wallet for the specified account.
The returned metadata value must exclude:
- spent notes;
- unspent notes excluded by the provided selector;
- unspent notes identified in the given
exclude
list.
Implementations of this method may limit the complexity of supported queries. Such limitations should be clearly documented for the implementing type.
Provided Methods§
Sourcefn get_unspent_transparent_output(
&self,
_outpoint: &OutPoint,
) -> Result<Option<WalletTransparentOutput>, Self::Error>
Available on crate feature transparent-inputs
only.
fn get_unspent_transparent_output( &self, _outpoint: &OutPoint, ) -> Result<Option<WalletTransparentOutput>, Self::Error>
transparent-inputs
only.Fetches the transparent output corresponding to the provided outpoint
.
Returns Ok(None)
if the UTXO is not known to belong to the wallet or is not
spendable as of the chain tip height.
Sourcefn get_spendable_transparent_outputs(
&self,
_address: &TransparentAddress,
_target_height: BlockHeight,
_min_confirmations: u32,
) -> Result<Vec<WalletTransparentOutput>, Self::Error>
Available on crate feature transparent-inputs
only.
fn get_spendable_transparent_outputs( &self, _address: &TransparentAddress, _target_height: BlockHeight, _min_confirmations: u32, ) -> Result<Vec<WalletTransparentOutput>, Self::Error>
transparent-inputs
only.Returns the list of spendable transparent outputs received by this wallet at address
such that, at height target_height
:
- the transaction that produced the output had or will have at least
min_confirmations
confirmations; and - the output is unspent as of the current chain tip.
An output that is potentially spent by an unmined transaction in the mempool is excluded
iff the spending transaction will not be expired at target_height
.