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: StringImplementations§
Source§impl CreatedWallet
impl CreatedWallet
Sourcepub fn into_wallet(self) -> UnlockedWallet
pub fn into_wallet(self) -> UnlockedWallet
Consume the pair, keeping only the wallet handle.
Sourcepub fn lock(self) -> Result<LockedWallet, BeekeeperError>
pub fn lock(self) -> Result<LockedWallet, BeekeeperError>
Forward of UnlockedWallet::lock (consuming methods cannot go
through Deref).
Sourcepub fn close(self) -> Result<(), BeekeeperError>
pub fn close(self) -> Result<(), BeekeeperError>
Forward of UnlockedWallet::close.
Methods from Deref<Target = UnlockedWallet>§
Sourcepub fn is_temporary(&self) -> bool
pub fn is_temporary(&self) -> bool
true when the wallet lives only in process memory and is never
persisted.
Sourcepub fn import_key(&mut self, wif_key: &str) -> Result<String, BeekeeperError>
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...").
Sourcepub fn remove_key(&mut self, public_key: &str) -> Result<(), BeekeeperError>
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.
Sourcepub fn has_matching_private_key(
&mut self,
public_key: &str,
) -> Result<bool, BeekeeperError>
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.
Sourcepub fn sign_digest(
&mut self,
public_key: &str,
digest_hex: &str,
) -> Result<String, BeekeeperError>
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.
Sourcepub fn get_public_keys(&mut self) -> Result<Vec<String>, BeekeeperError>
pub fn get_public_keys(&mut self) -> Result<Vec<String>, BeekeeperError>
Every public key held by the wallet, formatted with
DEFAULT_KEY_PREFIX.
Sourcepub fn encrypt_data<'k>(
&mut self,
from_key: &str,
to_key: impl Into<Option<&'k str>>,
content: &str,
nonce: u64,
) -> Result<String, BeekeeperError>
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.
Sourcepub fn decrypt_data<'k>(
&mut self,
from_key: &str,
to_key: impl Into<Option<&'k str>>,
encrypted_content: &str,
) -> Result<String, BeekeeperError>
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.