Struct wallet_core::Wallet
source · pub struct Wallet {
account: Wallet,
}
Expand description
the wallet
- use the
recover
function to recover the wallet from the mnemonics/password; - use the
retrieve_funds
to retrieve initial funds (if necessary) from the block0; then you can usetotal_value
to see how much was recovered from the initial block0;
Fields§
§account: Wallet
Implementations§
source§impl Wallet
impl Wallet
sourcepub fn account(&self, discrimination: Discrimination) -> Address
pub fn account(&self, discrimination: Discrimination) -> Address
Returns address of the account with the given chain discrimination.
pub fn id(&self) -> AccountId
sourcepub fn recover_free_keys(account_key: &[u8]) -> Result<Self, Error>
pub fn recover_free_keys(account_key: &[u8]) -> Result<Self, Error>
Retrieve a wallet from a key used as utxo’s
You can also use this function to recover a wallet even after you have transferred all the funds to the new format
Parameters
account_key
: the private key used for voting
Errors
The function may fail if:
TODO
sourcepub fn confirm_transaction(&mut self, id: FragmentId)
pub fn confirm_transaction(&mut self, id: FragmentId)
use this function to confirm a transaction has been properly received
This function will automatically update the state of the wallet
sourcepub fn spending_counter(&self) -> [u32; 8]
pub fn spending_counter(&self) -> [u32; 8]
get the current spending counter
sourcepub fn total_value(&self) -> Value
pub fn total_value(&self) -> Value
get the total value in the wallet
make sure to call retrieve_funds
prior to calling this function
otherwise you will always have 0
Once a conversion has been performed, this value can be use to display how much the wallet started with or retrieved from the chain.
sourcepub fn set_state(
&mut self,
value: Value,
counters: [u32; 8]
) -> Result<(), Error>
pub fn set_state( &mut self, value: Value, counters: [u32; 8] ) -> Result<(), Error>
Update the wallet’s account state.
The values to update the account state with can be retrieved from a Jormungandr API endpoint. It sets the balance value on the account as well as the current spending counter.
It is important to be sure to have an up to date wallet state before doing any transactions, otherwise future transactions may fail to be accepted by the blockchain nodes because of an invalid witness signature.
sourcepub fn vote(
&mut self,
settings: Settings,
proposal: &Proposal,
choice: Choice,
valid_until: &BlockDate,
lane: u8
) -> Result<Box<[u8]>, Error>
pub fn vote( &mut self, settings: Settings, proposal: &Proposal, choice: Choice, valid_until: &BlockDate, lane: u8 ) -> Result<Box<[u8]>, Error>
Cast a vote
This function outputs a fragment containing a voting transaction.
Parameters
settings
- ledger settings.proposal
- proposal information including the range of values allowed inchoice
.choice
- the option to vote for.
Errors
The error is returned when choice
does not fall withing the range of
available choices specified in proposal
.