Struct ethstore::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
sourceimpl SafeAccount
impl SafeAccount
sourcepub fn create(
keypair: &KeyPair,
id: [u8; 16],
password: &Password,
iterations: NonZeroU32,
name: String,
meta: String
) -> Result<Self, Error>
pub fn create(
keypair: &KeyPair,
id: [u8; 16],
password: &Password,
iterations: NonZeroU32,
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: NonZeroU32,
password: &Password
) -> Result<VaultKeyFile, Error>
pub fn into_vault_file(
self,
iterations: NonZeroU32,
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: NonZeroU32
) -> Result<Self, Error>
pub fn change_password(
&self,
old_password: &Password,
new_password: &Password,
iterations: NonZeroU32
) -> 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
sourceimpl Clone for SafeAccount
impl Clone for SafeAccount
sourcefn clone(&self) -> SafeAccount
fn clone(&self) -> SafeAccount
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SafeAccount
impl Debug for SafeAccount
sourceimpl PartialEq<SafeAccount> for SafeAccount
impl PartialEq<SafeAccount> for SafeAccount
sourcefn eq(&self, other: &SafeAccount) -> bool
fn eq(&self, other: &SafeAccount) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SafeAccount) -> bool
fn ne(&self, other: &SafeAccount) -> bool
This method tests for !=
.
impl StructuralPartialEq for SafeAccount
Auto Trait Implementations
impl RefUnwindSafe for SafeAccount
impl Send for SafeAccount
impl Sync for SafeAccount
impl Unpin for SafeAccount
impl UnwindSafe for SafeAccount
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more