pub trait WalletTest: InputSource + WalletRead {
// Required methods
fn get_tx_history(
&self,
) -> Result<Vec<TransactionSummary<<Self as WalletRead>::AccountId>>, <Self as WalletRead>::Error>;
fn get_sent_note_ids(
&self,
_txid: &TxId,
_protocol: ShieldedPool,
) -> Result<Vec<NoteId>, <Self as WalletRead>::Error>;
fn get_sent_outputs(
&self,
txid: &TxId,
) -> Result<Vec<OutputOfSentTx>, <Self as WalletRead>::Error>;
fn get_checkpoint_history(
&self,
protocol: &ShieldedPool,
) -> Result<Vec<(BlockHeight, Option<Position>)>, <Self as WalletRead>::Error>;
fn get_notes(
&self,
protocol: ShieldedPool,
) -> Result<Vec<ReceivedNote<Self::NoteRef, Note>>, <Self as InputSource>::Error>;
// Provided methods
fn get_transparent_output(
&self,
_outpoint: &OutPoint,
_spendable_as_of: Option<TargetHeight>,
) -> Result<Option<WalletTransparentOutput<<Self as WalletRead>::AccountId>>, <Self as InputSource>::Error> { ... }
fn get_known_ephemeral_addresses(
&self,
_account: <Self as WalletRead>::AccountId,
_index_range: Option<Range<NonHardenedChildIndex>>,
) -> Result<Vec<(TransparentAddress, TransparentAddressMetadata)>, <Self as WalletRead>::Error> { ... }
fn find_account_for_ephemeral_address(
&self,
address: &TransparentAddress,
) -> Result<Option<<Self as WalletRead>::AccountId>, <Self as WalletRead>::Error> { ... }
fn finally(&self) { ... }
}Expand description
Read-only operations required for testing light wallet functions.
These methods expose internal details or unstable interfaces, primarily to enable use
of the testing framework. They should not be used in production software.
Required Methods§
Sourcefn get_tx_history(
&self,
) -> Result<Vec<TransactionSummary<<Self as WalletRead>::AccountId>>, <Self as WalletRead>::Error>
fn get_tx_history( &self, ) -> Result<Vec<TransactionSummary<<Self as WalletRead>::AccountId>>, <Self as WalletRead>::Error>
Returns a vector of transaction summaries.
Currently test-only, as production use could return a very large number of results; either pagination or a streaming design will be necessary to stabilize this feature for production use.
Sourcefn get_sent_note_ids(
&self,
_txid: &TxId,
_protocol: ShieldedPool,
) -> Result<Vec<NoteId>, <Self as WalletRead>::Error>
fn get_sent_note_ids( &self, _txid: &TxId, _protocol: ShieldedPool, ) -> Result<Vec<NoteId>, <Self as WalletRead>::Error>
Returns the note IDs for shielded notes sent by the wallet in a particular transaction.
Sourcefn get_sent_outputs(
&self,
txid: &TxId,
) -> Result<Vec<OutputOfSentTx>, <Self as WalletRead>::Error>
fn get_sent_outputs( &self, txid: &TxId, ) -> Result<Vec<OutputOfSentTx>, <Self as WalletRead>::Error>
Returns the outputs for a transaction sent by the wallet.
fn get_checkpoint_history( &self, protocol: &ShieldedPool, ) -> Result<Vec<(BlockHeight, Option<Position>)>, <Self as WalletRead>::Error>
Sourcefn get_notes(
&self,
protocol: ShieldedPool,
) -> Result<Vec<ReceivedNote<Self::NoteRef, Note>>, <Self as InputSource>::Error>
fn get_notes( &self, protocol: ShieldedPool, ) -> Result<Vec<ReceivedNote<Self::NoteRef, Note>>, <Self as InputSource>::Error>
Returns all the notes that have been received by the wallet.
Provided Methods§
Sourcefn get_transparent_output(
&self,
_outpoint: &OutPoint,
_spendable_as_of: Option<TargetHeight>,
) -> Result<Option<WalletTransparentOutput<<Self as WalletRead>::AccountId>>, <Self as InputSource>::Error>
Available on crate feature transparent-inputs only.
fn get_transparent_output( &self, _outpoint: &OutPoint, _spendable_as_of: Option<TargetHeight>, ) -> Result<Option<WalletTransparentOutput<<Self as WalletRead>::AccountId>>, <Self as InputSource>::Error>
transparent-inputs only.Fetches the transparent output corresponding to the provided outpoint.
Allows selecting unspendable outputs for testing purposes.
§Parameters
outpoint: The identifier for the output to be retrieved.spendable_as_of: The target height of a transaction under construction that will spend the returned output. If this isNone, no spendability checks are performed.
Returns Ok(None) if the UTXO is not known to belong to the wallet or if spendable_as_of
is set and the output is available to be spent by the wallet in a transaction that is
intended to be mined at the target height.
Sourcefn get_known_ephemeral_addresses(
&self,
_account: <Self as WalletRead>::AccountId,
_index_range: Option<Range<NonHardenedChildIndex>>,
) -> Result<Vec<(TransparentAddress, TransparentAddressMetadata)>, <Self as WalletRead>::Error>
Available on crate feature transparent-inputs only.
fn get_known_ephemeral_addresses( &self, _account: <Self as WalletRead>::AccountId, _index_range: Option<Range<NonHardenedChildIndex>>, ) -> Result<Vec<(TransparentAddress, TransparentAddressMetadata)>, <Self as WalletRead>::Error>
transparent-inputs only.Returns a vector of ephemeral transparent addresses associated with the given account controlled by this wallet, along with their metadata. The result includes reserved addresses, and addresses for the backend’s configured gap limit worth of additional indices (capped to the maximum index).
If index_range is some Range, it limits the result to addresses with indices
in that range. An index_range of None is defined to be equivalent to
0..(1u32 << 31).
Wallets should scan the chain for UTXOs sent to these ephemeral transparent receivers, but do not need to do so regularly. Under expected usage, outputs would only be detected with these receivers in the following situations:
-
This wallet created a payment to a ZIP 320 (TEX) address, but the second transaction (that spent the output sent to the ephemeral address) did not get mined before it expired.
- In this case the output will already be known to the wallet (because it stores the transactions that it creates).
-
Another wallet app using the same seed phrase created a payment to a ZIP 320 address, and this wallet queried for the ephemeral UTXOs after the first transaction was mined but before the second transaction was mined.
- In this case, the output should not be considered unspent until the expiry height of the transaction it was received in has passed. Wallets creating payments to TEX addresses generally set the same expiry height for the first and second transactions, meaning that this wallet does not need to observe the second transaction to determine when it would have expired.
-
A TEX address recipient decided to return funds that the wallet had sent to them.
In all cases, the wallet should re-shield the unspent outputs, in a separate transaction per ephemeral address, before re-spending the funds.
Sourcefn find_account_for_ephemeral_address(
&self,
address: &TransparentAddress,
) -> Result<Option<<Self as WalletRead>::AccountId>, <Self as WalletRead>::Error>
Available on crate feature transparent-inputs only.
fn find_account_for_ephemeral_address( &self, address: &TransparentAddress, ) -> Result<Option<<Self as WalletRead>::AccountId>, <Self as WalletRead>::Error>
transparent-inputs only.If a given ephemeral address might have been reserved, i.e. would be included in
the result of get_known_ephemeral_addresses(account_id, None) for any of the
wallet’s accounts, then return Ok(Some(account_id)). Otherwise return Ok(None).
This is equivalent to (but may be implemented more efficiently than):
for account_id in self.get_account_ids()? {
if self
.get_known_ephemeral_addresses(account_id, None)?
.into_iter()
.any(|(known_addr, _)| &known_addr == address)
{
return Ok(Some(account_id));
}
}
Ok(None)Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".