Skip to main content

CreatedWallet

Struct CreatedWallet 

Source
pub struct CreatedWallet {
    pub wallet: UnlockedWallet,
    pub password: String,
}
Expand description

Result of Session::create_wallet.

password is whichever password ended up protecting the wallet — either the caller-supplied value, or the generated one when None was passed.

Dereferences to the contained UnlockedWallet, so key operations can be called on it directly:

let mut created = session.create_wallet("w0", "password").unwrap();
let pubkey = created.import_key("5J...wif...").unwrap();

Fields§

§wallet: UnlockedWallet§password: String

Implementations§

Source§

impl CreatedWallet

Source

pub fn into_wallet(self) -> UnlockedWallet

Consume the pair, keeping only the wallet handle.

Source

pub fn lock(self) -> Result<LockedWallet, BeekeeperError>

Forward of UnlockedWallet::lock (consuming methods cannot go through Deref).

Source

pub fn close(self) -> Result<(), BeekeeperError>

Methods from Deref<Target = UnlockedWallet>§

Source

pub fn name(&self) -> &str

The wallet’s name, as passed to create_wallet / open_wallet.

Source

pub fn is_temporary(&self) -> bool

true when the wallet lives only in process memory and is never persisted.

Source

pub fn import_key(&mut self, wif_key: &str) -> Result<String, BeekeeperError>

Import a WIF-encoded private key and return its public counterpart.

The returned key is base58 with the DEFAULT_KEY_PREFIX prefix (e.g. "STM7...").

Source

pub fn remove_key(&mut self, public_key: &str) -> Result<(), BeekeeperError>

Remove the private key matching public_key (STM…).

Errors when no such key exists in the wallet.

Source

pub fn has_matching_private_key( &mut self, public_key: &str, ) -> Result<bool, BeekeeperError>

true when the wallet contains the private key for public_key.

Source

pub fn sign_digest( &mut self, public_key: &str, digest_hex: &str, ) -> Result<String, BeekeeperError>

Sign a pre-computed digest with the private key matching public_key.

digest_hex must be the hex encoding of a 32-byte digest. The returned signature is the hex encoding of the 65-byte compact signature.

Source

pub fn get_public_keys(&mut self) -> Result<Vec<String>, BeekeeperError>

Every public key held by the wallet, formatted with DEFAULT_KEY_PREFIX.

Source

pub fn encrypt_data<'k>( &mut self, from_key: &str, to_key: impl Into<Option<&'k str>>, content: &str, nonce: u64, ) -> Result<String, BeekeeperError>

Encrypt content between two keys, returning a base58 buffer.

from_key must be present in the wallet (its private key is used for the ECDH side). to_key accepts anything convertible into Option<&str>; None is interpreted as self-encryption (to_key = from_key).

nonce is mixed into the encryption to make output reproducible; pass 0 to have the C++ side generate a random nonce instead.

Source

pub fn decrypt_data<'k>( &mut self, from_key: &str, to_key: impl Into<Option<&'k str>>, encrypted_content: &str, ) -> Result<String, BeekeeperError>

Decrypt a base58 buffer produced by encrypt_data.

to_key = None defaults to from_key, mirroring the encrypt side.

Trait Implementations§

Source§

impl Deref for CreatedWallet

Source§

type Target = UnlockedWallet

The resulting type after dereferencing.
Source§

fn deref(&self) -> &UnlockedWallet

Dereferences the value.
Source§

impl DerefMut for CreatedWallet

Source§

fn deref_mut(&mut self) -> &mut UnlockedWallet

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T, U> Into<U> for T
where 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.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.