Struct Wallet

Source
pub struct Wallet { /* private fields */ }
Expand description

Essential Wallet USE AT YOUR OWN RISK! Stores secret keys in sqlcipher database.

Implementations§

Source§

impl Wallet

Source

pub fn new(password: &str, path: PathBuf) -> Result<Self>

Create a new wallet with a password and directory.

Source

pub fn with_default_path(password: &str) -> Result<Self>

Create a new wallet with a password.

The wallet will find a suitable directory to store the database.

Source

pub fn new_key_pair(&mut self, name: &str, scheme: Scheme) -> Result<()>

Create a new key pair. The key pair will be stored in the OS self.store. The key will be stored at the name provided. The scheme determines which signature scheme to use.

Source

pub fn delete_key_pair(&mut self, name: &str) -> Result<()>

Delete a key pair at this name.

Source

pub fn list_names(&mut self) -> Result<Vec<String>>

List all names for key pairs stored in the OS self.store for this service.

Source

pub fn get_public_key(&mut self, name: &str) -> Result<PublicKey>

Get the public key for this key pair.

Source

pub fn get_private_key(&mut self, name: &str) -> Result<Key>

Get the private key for this key pair.

Source

pub fn sign_contract( &mut self, data: Contract, name: &str, ) -> Result<SignedContract>

Sign an contract.

Requires the keypair be a secp256k1 key or this will return an error. No padding is applied to the data before signing. This is designed to be used for deploying contracts to the api.

Source

pub fn sign_postcard<T: Serialize>( &mut self, data: &T, name: &str, ) -> Result<Signature>

Create a signature using the key pair stored at this name.

The data will be serialized as postcard, then hashed and the hash signed. No padding is applied to the data before signing.

Source

pub fn sign_postcard_with_padding<T: Serialize>( &mut self, data: &T, padding: Padding, name: &str, ) -> Result<Signature>

Create a signature using the key pair stored at this name.

The data will be serialized as postcard, then padded to be word aligned, then hashed and the hash signed.

Source

pub fn sign_hash(&mut self, data: Hash, name: &str) -> Result<Signature>

Create a signature using the key pair stored at this name.

Source

pub fn sign_words(&mut self, data: &[Word], name: &str) -> Result<Signature>

Create a signature using the key pair stored at this name.

Source

pub fn sign_bytes_with_padding( &mut self, data: Vec<u8>, padding: Padding, name: &str, ) -> Result<Signature>

Create a signature using the key pair stored at this name.

The data will be padded to be word aligned, then hashed and the hash signed.

Source

pub fn sign_aligned_bytes( &mut self, data: &[u8], name: &str, ) -> Result<Signature>

Create a signature using the key pair stored at this name.

The data will be hashed and the hash signed. This will return an error if the data is not word aligned.

Source

pub fn sign_bytes_unchecked( &mut self, data: &[u8], name: &str, ) -> Result<Signature>

Create a signature using the key pair stored at this name.

The data will be hashed and the hash signed. Word alignment is not checked.

Auto Trait Implementations§

§

impl !Freeze for Wallet

§

impl !RefUnwindSafe for Wallet

§

impl Send for Wallet

§

impl !Sync for Wallet

§

impl Unpin for Wallet

§

impl !UnwindSafe for Wallet

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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 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.
Source§

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

Source§

fn vzip(self) -> V