T3 Wallet Restore fix and refactor (#1202)

* clean up wallet restore and underlying functions

* rustfmt

* refactor restore
This commit is contained in:
Yeastplume
2018-06-26 18:24:40 +01:00
committed by GitHub
parent 14667bfad6
commit ccf862f76b
12 changed files with 377 additions and 274 deletions
+11 -8
View File
@@ -162,22 +162,25 @@ pub struct Output {
impl Output {
pub fn new(commit: &pedersen::Commitment) -> Output {
Output {
commit: PrintableCommitment(commit.clone()),
commit: PrintableCommitment {
commit: commit.clone(),
},
}
}
}
#[derive(Debug, Clone)]
pub struct PrintableCommitment(pedersen::Commitment);
pub struct PrintableCommitment {
pub commit: pedersen::Commitment,
}
impl PrintableCommitment {
pub fn commit(&self) -> pedersen::Commitment {
self.0.clone()
self.commit.clone()
}
pub fn to_vec(&self) -> Vec<u8> {
let commit = self.0;
commit.0.to_vec()
self.commit.0.to_vec()
}
}
@@ -212,9 +215,9 @@ impl<'de> serde::de::Visitor<'de> for PrintableCommitmentVisitor {
where
E: serde::de::Error,
{
Ok(PrintableCommitment(pedersen::Commitment::from_vec(
util::from_hex(String::from(v)).unwrap(),
)))
Ok(PrintableCommitment {
commit: pedersen::Commitment::from_vec(util::from_hex(String::from(v)).unwrap()),
})
}
}