Struct cfxstore::SafeAccount
source · pub struct SafeAccount {
pub id: [u8; 16],
pub version: Version,
pub address: Address,
pub crypto: Crypto,
pub filename: Option<String>,
pub name: String,
pub meta: String,
}
Expand description
Account representation.
Fields§
§id: [u8; 16]
Account ID
version: Version
Account version
address: Address
Account address
crypto: Crypto
Account private key derivation definition.
filename: Option<String>
Account filename
name: String
Account name
meta: String
Account metadata
Implementations§
source§impl SafeAccount
impl SafeAccount
sourcepub fn create(
keypair: &KeyPair,
id: [u8; 16],
password: &Password,
iterations: u32,
name: String,
meta: String
) -> Result<Self, Error>
pub fn create( keypair: &KeyPair, id: [u8; 16], password: &Password, iterations: u32, name: String, meta: String ) -> Result<Self, Error>
Create a new account
sourcepub fn from_file(
json: KeyFile,
filename: Option<String>,
password: &Option<Password>
) -> Result<Self, Error>
pub fn from_file( json: KeyFile, filename: Option<String>, password: &Option<Password> ) -> Result<Self, Error>
Create a new SafeAccount
from the given json
; if it was read from a
file, the filename
should be Some
name. If it is as yet anonymous,
then it can be left None
.
In case password
is provided, we will attempt to read the secret from
the keyfile and derive the address from it instead of reading it
directly. Providing password is required for json::KeyFile
s with
no address.
sourcepub fn from_vault_file(
password: &Password,
json: VaultKeyFile,
filename: Option<String>
) -> Result<Self, Error>
pub fn from_vault_file( password: &Password, json: VaultKeyFile, filename: Option<String> ) -> Result<Self, Error>
Create a new SafeAccount
from the given vault json
; if it was read
from a file, the filename
should be Some
name. If it is as yet
anonymous, then it can be left None
.
sourcepub fn into_vault_file(
self,
iterations: u32,
password: &Password
) -> Result<VaultKeyFile, Error>
pub fn into_vault_file( self, iterations: u32, password: &Password ) -> Result<VaultKeyFile, Error>
Create a new VaultKeyFile
from the given self
sourcepub fn sign(
&self,
password: &Password,
message: &Message
) -> Result<Signature, Error>
pub fn sign( &self, password: &Password, message: &Message ) -> Result<Signature, Error>
Sign a message.
sourcepub fn decrypt(
&self,
password: &Password,
shared_mac: &[u8],
message: &[u8]
) -> Result<Vec<u8>, Error>
pub fn decrypt( &self, password: &Password, shared_mac: &[u8], message: &[u8] ) -> Result<Vec<u8>, Error>
Decrypt a message.
sourcepub fn agree(
&self,
password: &Password,
other: &Public
) -> Result<Secret, Error>
pub fn agree( &self, password: &Password, other: &Public ) -> Result<Secret, Error>
Agree on shared key.
sourcepub fn change_password(
&self,
old_password: &Password,
new_password: &Password,
iterations: u32
) -> Result<Self, Error>
pub fn change_password( &self, old_password: &Password, new_password: &Password, iterations: u32 ) -> Result<Self, Error>
Change account’s password.
sourcepub fn check_password(&self, password: &Password) -> bool
pub fn check_password(&self, password: &Password) -> bool
Check if password matches the account.
Trait Implementations§
source§impl Clone for SafeAccount
impl Clone for SafeAccount
source§fn clone(&self) -> SafeAccount
fn clone(&self) -> SafeAccount
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SafeAccount
impl Debug for SafeAccount
source§impl PartialEq for SafeAccount
impl PartialEq for SafeAccount
source§fn eq(&self, other: &SafeAccount) -> bool
fn eq(&self, other: &SafeAccount) -> bool
self
and other
values to be equal, and is used
by ==
.