feat: works
This commit is contained in:
@@ -10,6 +10,7 @@ use std::str::FromStr;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct JsonKeyPair {
|
||||
pub identity: String,
|
||||
pub pri_key: String,
|
||||
pub pub_key: String,
|
||||
}
|
||||
@@ -17,13 +18,18 @@ pub struct JsonKeyPair {
|
||||
impl JsonKeyPair {
|
||||
pub fn from(pri_key: SecretKey, pub_key: PublicKey) -> Self {
|
||||
JsonKeyPair {
|
||||
identity: make_btc_address(&pub_key),
|
||||
pri_key: format!("{}", pri_key),
|
||||
pub_key: format!("{}", pub_key),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_json(&self) -> XResult<String> {
|
||||
serde_json::to_string(self).map_err(|e| e.into())
|
||||
serde_json::to_string_pretty(self).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
pub fn from_json(json: &str) -> XResult<Self> {
|
||||
serde_json::from_str(json).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
pub fn to_key_pair(&self) -> XResult<(SecretKey, PublicKey)> {
|
||||
|
||||
Reference in New Issue
Block a user