pub fn find_account_for_address<W: WalletRead, P: Parameters>(
wallet: &W,
params: &P,
address: &Address,
) -> Result<Option<W::AccountId>, FindAccountForAddressError<W::Error>>Expand description
Reference implementation of WalletRead::find_account_for_address.
Any address whose shielded component can be represented as a UnifiedAddress — either
directly, or by synthesizing a single-receiver UA around a bare Sapling address — is
first resolved via UIVK algebra: each account’s
UnifiedIncomingViewingKey::decrypt_diversifiers is asked whether it could have derived
any shielded receiver of the (possibly synthesized) UA. An account matches if at least
one shielded receiver is attributable to it, which finds addresses the account could
produce even if they have never been exposed. If more than one account matches,
FindAccountForAddressError::UnifiedAddressConflict is returned.
If the algebraic step does not resolve a match (or the address has no shielded receiver,
as is the case for transparent and TEX addresses), this falls back to a linear scan over
each account’s tracked addresses via WalletRead::list_addresses, returning the first
account that holds a matching address (as an exact match, or as a receiver embedded in a
stored UA).
Backends that can answer this query more efficiently (e.g. via an indexed database
lookup) should implement WalletRead::find_account_for_address directly rather than
delegating to this function.
See WalletRead::find_account_for_address for the semantics of the return value.