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 use total_value to see how much was recovered from the initial block0;

Fields§

§account: Wallet

Implementations§

source§

impl Wallet

source

pub fn account(&self, discrimination: Discrimination) -> Address

Returns address of the account with the given chain discrimination.

source

pub fn id(&self) -> AccountId

source

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

source

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

source

pub fn spending_counter(&self) -> [u32; 8]

get the current spending counter

source

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.

source

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.

source

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 in choice.
  • 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.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more