pub trait AddressStore {
type Error;
type AccountRef: Copy + Eq + Hash;
// Required methods
fn find_gap_start(
&self,
account_ref: Self::AccountRef,
key_scope: TransparentKeyScope,
gap_limit: u32,
) -> Result<Option<NonHardenedChildIndex>, Self::Error>;
fn store_address_range(
&mut self,
account_id: Self::AccountRef,
key_scope: TransparentKeyScope,
list: Vec<(Address, TransparentAddress, NonHardenedChildIndex)>,
) -> Result<(), Self::Error>;
fn reconcile_stored_addresses(
&mut self,
account_id: Self::AccountRef,
key_scope: TransparentKeyScope,
added: &[(Address, TransparentAddress, NonHardenedChildIndex)],
) -> Result<ReconcileOutcome, Self::Error>;
}transparent-inputs only.Expand description
A trait providing wallet storage operations required for transparent address gap limit management.
Implementations of this trait allow the gap limit logic in generate_gap_addresses to query
and update the wallet’s transparent address state without being coupled to a specific storage
backend.
Required Associated Types§
Sourcetype AccountRef: Copy + Eq + Hash
type AccountRef: Copy + Eq + Hash
A wallet-internal account identifier.
Required Methods§
Sourcefn find_gap_start(
&self,
account_ref: Self::AccountRef,
key_scope: TransparentKeyScope,
gap_limit: u32,
) -> Result<Option<NonHardenedChildIndex>, Self::Error>
fn find_gap_start( &self, account_ref: Self::AccountRef, key_scope: TransparentKeyScope, gap_limit: u32, ) -> Result<Option<NonHardenedChildIndex>, Self::Error>
Returns the transparent address index at the start of the first gap of at least gap_limit
indices in the given account, considering only addresses derived for the specified key scope.
Returns Ok(None) if the gap would start at an index greater than the maximum valid
non-hardened transparent child index.
Sourcefn store_address_range(
&mut self,
account_id: Self::AccountRef,
key_scope: TransparentKeyScope,
list: Vec<(Address, TransparentAddress, NonHardenedChildIndex)>,
) -> Result<(), Self::Error>
fn store_address_range( &mut self, account_id: Self::AccountRef, key_scope: TransparentKeyScope, list: Vec<(Address, TransparentAddress, NonHardenedChildIndex)>, ) -> Result<(), Self::Error>
Persists a range of derived transparent addresses to the wallet storage.
Each entry in the list contains the wallet-level address, the raw transparent address, and the child index from which the address was derived.
Sourcefn reconcile_stored_addresses(
&mut self,
account_id: Self::AccountRef,
key_scope: TransparentKeyScope,
added: &[(Address, TransparentAddress, NonHardenedChildIndex)],
) -> Result<ReconcileOutcome, Self::Error>
fn reconcile_stored_addresses( &mut self, account_id: Self::AccountRef, key_scope: TransparentKeyScope, added: &[(Address, TransparentAddress, NonHardenedChildIndex)], ) -> Result<ReconcileOutcome, Self::Error>
Checks addresses that have just been added to the wallet against transaction involvement the wallet has already observed, and records whatever that reveals.
A wallet recognizes transparent involvement by joining the transactions it stores against the addresses it holds, and both sides of that join change over time: a transaction may arrive after the address it pays is held, and an address may be added after a transaction naming it is stored. Checking each newly stored transaction against the address book maintains only the first case; an implementation of this method maintains the second. Without one, a transaction stored before its address entered the wallet is never recognized.
added is the list just passed to Self::store_address_range, in the same form. An
implementation must consider every entry, including entries that were already stored:
storing a range is idempotent and carries no record of which entries were new.
Returns ReconcileOutcome::AddressesUsed if, as a result of this check, any address in
added is now known to have received an output in a mined transaction, carrying the
highest child index among those addresses. Returns ReconcileOutcome::Unchanged
otherwise. generate_gap_addresses uses the answer to decide whether the account’s gap
start has moved, and so whether a further window of addresses must be derived and checked
in turn.
This method must be idempotent: repeated calls with the same addresses must not record anything beyond what the first call recorded.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".