1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#![forbid(unsafe_code)]
#![deny(missing_docs)]
use diem_crypto::{
ed25519::{Ed25519PrivateKey, Ed25519PublicKey},
test_utils::KeyPair,
traits::ValidCryptoMaterialStringExt,
};
use diem_types::account_address::AccountAddress;
use serde::{Deserialize, Serialize};
mod account_commands;
pub mod client_proxy;
pub mod commands;
mod counters;
mod dev_commands;
mod diem_client;
mod info_commands;
mod query_commands;
mod transfer_commands;
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(any(test, feature = "fuzzing"), derive(Clone))]
pub struct AccountData {
pub address: AccountAddress,
pub authentication_key: Option<Vec<u8>>,
pub key_pair: Option<KeyPair<Ed25519PrivateKey, Ed25519PublicKey>>,
pub sequence_number: u64,
pub status: AccountStatus,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum AccountStatus {
Local,
Persisted,
Unknown,
}
impl AccountData {
pub fn keypair_as_string(&self) -> Option<(String, String)> {
self.key_pair.as_ref().map(|key_pair| {
let private_key_string = key_pair
.private_key
.to_encoded_string()
.expect("Account private key to convertible to string!");
let public_key_string = key_pair
.public_key
.to_encoded_string()
.expect("Account public Key not convertible to string!");
(private_key_string, public_key_string)
})
}
}