pub struct Wallet { /* private fields */ }
Expand description
Essential Wallet USE AT YOUR OWN RISK! Stores secret keys in sqlcipher database.
Implementations§
Source§impl Wallet
impl Wallet
Sourcepub fn new(password: &str, path: PathBuf) -> Result<Self>
pub fn new(password: &str, path: PathBuf) -> Result<Self>
Create a new wallet with a password and directory.
Sourcepub fn with_default_path(password: &str) -> Result<Self>
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.
Sourcepub fn new_key_pair(&mut self, name: &str, scheme: Scheme) -> Result<()>
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.
Sourcepub fn delete_key_pair(&mut self, name: &str) -> Result<()>
pub fn delete_key_pair(&mut self, name: &str) -> Result<()>
Delete a key pair at this name.
Sourcepub fn list_names(&mut self) -> Result<Vec<String>>
pub fn list_names(&mut self) -> Result<Vec<String>>
List all names for key pairs stored in the OS self.store for this service.
Sourcepub fn get_public_key(&mut self, name: &str) -> Result<PublicKey>
pub fn get_public_key(&mut self, name: &str) -> Result<PublicKey>
Get the public key for this key pair.
Sourcepub fn get_private_key(&mut self, name: &str) -> Result<Key>
pub fn get_private_key(&mut self, name: &str) -> Result<Key>
Get the private key for this key pair.
Sourcepub fn sign_contract(
&mut self,
data: Contract,
name: &str,
) -> Result<SignedContract>
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.
Sourcepub fn sign_postcard<T: Serialize>(
&mut self,
data: &T,
name: &str,
) -> Result<Signature>
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.
Sourcepub fn sign_postcard_with_padding<T: Serialize>(
&mut self,
data: &T,
padding: Padding,
name: &str,
) -> Result<Signature>
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.
Sourcepub fn sign_hash(&mut self, data: Hash, name: &str) -> Result<Signature>
pub fn sign_hash(&mut self, data: Hash, name: &str) -> Result<Signature>
Create a signature using the key pair stored at this name.
Sourcepub fn sign_words(&mut self, data: &[Word], name: &str) -> Result<Signature>
pub fn sign_words(&mut self, data: &[Word], name: &str) -> Result<Signature>
Create a signature using the key pair stored at this name.
Sourcepub fn sign_bytes_with_padding(
&mut self,
data: Vec<u8>,
padding: Padding,
name: &str,
) -> Result<Signature>
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.