Merge branch 'master' of github.com:adityapk00/zecwallet-light-cli

This commit is contained in:
Aditya Kulkarni
2020-07-29 09:59:25 -07:00
4 changed files with 55 additions and 19 deletions

View File

@@ -2074,22 +2074,12 @@ impl LightWallet {
Some(s) => {
// If the string starts with an "0x", and contains only hex chars ([a-f0-9]+) then
// interpret it as a hex
let s_bytes = if s.to_lowercase().starts_with("0x") {
match hex::decode(&s[2..s.len()]) {
Ok(data) => data,
Err(_) => Vec::from(s.as_bytes())
}
} else {
Vec::from(s.as_bytes())
};
match Memo::from_bytes(&s_bytes) {
None => {
let e = format!("Error creating output. Memo {:?} is too long", s);
match utils::interpret_memo_string(&s) {
Ok(m) => Some(m),
Err(e) => {
error!("{}", e);
return Err(e);
},
Some(m) => Some(m)
}
}
}
};
@@ -2162,10 +2152,16 @@ impl LightWallet {
None => Memo::default(),
Some(s) => {
// If the address is not a z-address, then drop the memo
if LightWallet::is_shielded_address(&addr.to_string(), &self.config) {
Memo::from_bytes(s.as_bytes()).unwrap()
} else {
if !LightWallet::is_shielded_address(&addr.to_string(), &self.config) {
Memo::default()
} else {
match utils::interpret_memo_string(s) {
Ok(m) => m,
Err(e) => {
error!("{}", e);
Memo::default()
}
}
}
}
},