pub struct Wallet {
account: EitherAccount,
state: States<FragmentId, State>,
}
Fields§
§account: EitherAccount
§state: States<FragmentId, State>
Implementations§
source§impl Wallet
impl Wallet
pub fn new_from_seed(seed: Seed) -> Self
pub fn new_from_key(key: SecretKey<Ed25519Extended>) -> Self
pub fn account_id(&self) -> AccountId
pub fn secret_key(&self) -> AccountSecretKey
sourcepub fn set_state(
&mut self,
value: Value,
counters: [SpendingCounter; 8]
) -> Result<(), Error>
pub fn set_state( &mut self, value: Value, counters: [SpendingCounter; 8] ) -> Result<(), Error>
set the state counter so we can sync with the blockchain and the local state
TODO: some handling to provide information if needed:
- check the counter is not regressing?
- check that there is continuity?
TODO: change to a constructor/initializator?, or just make it so it resets the state
pub fn spending_counter(&self) -> [SpendingCounter; 8]
pub fn value(&self) -> Value
sourcepub fn confirm(&mut self, fragment_id: &FragmentId)
pub fn confirm(&mut self, fragment_id: &FragmentId)
confirm a pending transaction
to only do once it is confirmed a transaction is on chain and is far enough in the blockchain history to be confirmed as immutable
sourcepub fn pending_transactions(&self) -> impl Iterator<Item = &FragmentId>
pub fn pending_transactions(&self) -> impl Iterator<Item = &FragmentId>
get all the pending transactions of the wallet
If empty it means there’s no pending transactions waiting confirmation
sourcepub fn confirmed_value(&self) -> Value
pub fn confirmed_value(&self) -> Value
get the confirmed value of the wallet
sourcepub fn unconfirmed_value(&self) -> Option<Value>
pub fn unconfirmed_value(&self) -> Option<Value>
get the unconfirmed value of the wallet
if None
, it means there is no unconfirmed state of the wallet
and the value can be known from confirmed_value
.
The returned value is the value we expect to see at some point on chain once all transactions are on chain confirmed.