Support z -> t transactions

This commit is contained in:
Aditya Kulkarni 2019-09-09 11:17:35 -07:00
parent 8547235b28
commit 84ec286f7f
2 changed files with 15 additions and 21 deletions

View File

@ -29,28 +29,22 @@ impl From<TransparentAddress> for RecipientAddress {
impl RecipientAddress { impl RecipientAddress {
pub fn from_str(s: &str) -> Option<Self> { pub fn from_str(s: &str) -> Option<Self> {
// Try to match a sapling z address
if let Some(pa) = match decode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS, s) { if let Some(pa) = match decode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS, s) {
Ok(ret) => ret, Ok(ret) => ret,
Err(e) => { Err(_) => None
eprintln!("{}", e); }
return None; {
} Some(RecipientAddress::Shielded(pa)) // Matched a shielded address
} {
Some(RecipientAddress::Shielded(pa))
} else if let Some(addr) = match decode_transparent_address( } else if let Some(addr) = match decode_transparent_address(
&B58_PUBKEY_ADDRESS_PREFIX, &B58_PUBKEY_ADDRESS_PREFIX, &B58_SCRIPT_ADDRESS_PREFIX, s) {
&B58_SCRIPT_ADDRESS_PREFIX, Ok(ret) => ret,
s, Err(_) => None
) { }
Ok(ret) => ret, {
Err(e) => { Some(RecipientAddress::Transparent(addr)) // Matched a transparent address
eprintln!("{}", e);
return None;
}
} {
Some(RecipientAddress::Transparent(addr))
} else { } else {
None None // Didn't match anything
} }
} }
} }

View File

@ -89,9 +89,9 @@ impl Command for SendCommand {
fn exec(&self, _args: &[String], lightclient: &mut LightClient) { fn exec(&self, _args: &[String], lightclient: &mut LightClient) {
lightclient.do_send( lightclient.do_send(
"ztestsapling1x65nq4dgp0qfywgxcwk9n0fvm4fysmapgr2q00p85ju252h6l7mmxu2jg9cqqhtvzd69jwhgv8d".to_string(), "tmHYDCK6PjBMArtDXwPf5bgoFm2Na5fR6Ds".to_string(),
150000, 150000,
Some("Hello from the command".to_string())); None);
} }
} }