zcash_client_backend: Rename `RecipientAddress::Shielded` to `RecipientAddress::Sapling`
This commit is contained in:
parent
ecd5402266
commit
aab9938b53
|
@ -181,6 +181,9 @@ and this library adheres to Rust's notion of
|
||||||
- `ReceivedSaplingNote::value`
|
- `ReceivedSaplingNote::value`
|
||||||
- `WalletTransparentOutput::value`
|
- `WalletTransparentOutput::value`
|
||||||
|
|
||||||
|
- `zcash_client_backend::address`:
|
||||||
|
- `RecipientAddress::Shielded` has been renamed to `RecipientAddress::Sapling`
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- `zcash_client_backend::wallet::ReceivedSaplingNote` has been replaced by
|
- `zcash_client_backend::wallet::ReceivedSaplingNote` has been replaced by
|
||||||
`zcash_client_backend::ReceivedNote`.
|
`zcash_client_backend::ReceivedNote`.
|
||||||
|
|
|
@ -176,14 +176,14 @@ impl UnifiedAddress {
|
||||||
// TODO: rename to ParsedAddress
|
// TODO: rename to ParsedAddress
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum RecipientAddress {
|
pub enum RecipientAddress {
|
||||||
Shielded(PaymentAddress),
|
Sapling(PaymentAddress),
|
||||||
Transparent(TransparentAddress),
|
Transparent(TransparentAddress),
|
||||||
Unified(UnifiedAddress),
|
Unified(UnifiedAddress),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PaymentAddress> for RecipientAddress {
|
impl From<PaymentAddress> for RecipientAddress {
|
||||||
fn from(addr: PaymentAddress) -> Self {
|
fn from(addr: PaymentAddress) -> Self {
|
||||||
RecipientAddress::Shielded(addr)
|
RecipientAddress::Sapling(addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ impl RecipientAddress {
|
||||||
let net = params.address_network().expect("Unrecognized network");
|
let net = params.address_network().expect("Unrecognized network");
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
RecipientAddress::Shielded(pa) => ZcashAddress::from_sapling(net, pa.to_bytes()),
|
RecipientAddress::Sapling(pa) => ZcashAddress::from_sapling(net, pa.to_bytes()),
|
||||||
RecipientAddress::Transparent(addr) => match addr {
|
RecipientAddress::Transparent(addr) => match addr {
|
||||||
TransparentAddress::PublicKey(data) => {
|
TransparentAddress::PublicKey(data) => {
|
||||||
ZcashAddress::from_transparent_p2pkh(net, *data)
|
ZcashAddress::from_transparent_p2pkh(net, *data)
|
||||||
|
|
|
@ -679,7 +679,7 @@ where
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RecipientAddress::Shielded(addr) => {
|
RecipientAddress::Sapling(addr) => {
|
||||||
let memo = payment
|
let memo = payment
|
||||||
.memo
|
.memo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -513,7 +513,7 @@ where
|
||||||
RecipientAddress::Transparent(addr) => {
|
RecipientAddress::Transparent(addr) => {
|
||||||
push_transparent(*addr);
|
push_transparent(*addr);
|
||||||
}
|
}
|
||||||
RecipientAddress::Shielded(_) => {
|
RecipientAddress::Sapling(_) => {
|
||||||
push_sapling();
|
push_sapling();
|
||||||
}
|
}
|
||||||
RecipientAddress::Unified(addr) => {
|
RecipientAddress::Unified(addr) => {
|
||||||
|
|
|
@ -554,7 +554,7 @@ mod parse {
|
||||||
match v {
|
match v {
|
||||||
Param::Amount(a) => payment.amount = a,
|
Param::Amount(a) => payment.amount = a,
|
||||||
Param::Memo(m) => match payment.recipient_address {
|
Param::Memo(m) => match payment.recipient_address {
|
||||||
RecipientAddress::Shielded(_) | RecipientAddress::Unified(_) => {
|
RecipientAddress::Sapling(_) | RecipientAddress::Unified(_) => {
|
||||||
payment.memo = Some(m)
|
payment.memo = Some(m)
|
||||||
}
|
}
|
||||||
RecipientAddress::Transparent(_) => {
|
RecipientAddress::Transparent(_) => {
|
||||||
|
@ -770,7 +770,7 @@ pub mod testing {
|
||||||
|
|
||||||
pub fn arb_addr() -> impl Strategy<Value = RecipientAddress> {
|
pub fn arb_addr() -> impl Strategy<Value = RecipientAddress> {
|
||||||
prop_oneof![
|
prop_oneof![
|
||||||
arb_payment_address().prop_map(RecipientAddress::Shielded),
|
arb_payment_address().prop_map(RecipientAddress::Sapling),
|
||||||
arb_transparent_addr().prop_map(RecipientAddress::Transparent),
|
arb_transparent_addr().prop_map(RecipientAddress::Transparent),
|
||||||
arb_unified_addr().prop_map(RecipientAddress::Unified),
|
arb_unified_addr().prop_map(RecipientAddress::Unified),
|
||||||
]
|
]
|
||||||
|
@ -797,7 +797,7 @@ pub mod testing {
|
||||||
|
|
||||||
let is_shielded = match recipient_address {
|
let is_shielded = match recipient_address {
|
||||||
RecipientAddress::Transparent(_) => false,
|
RecipientAddress::Transparent(_) => false,
|
||||||
RecipientAddress::Shielded(_) | RecipientAddress::Unified(_) => true,
|
RecipientAddress::Sapling(_) | RecipientAddress::Unified(_) => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
Payment {
|
Payment {
|
||||||
|
@ -899,7 +899,7 @@ mod tests {
|
||||||
let expected = TransactionRequest {
|
let expected = TransactionRequest {
|
||||||
payments: vec![
|
payments: vec![
|
||||||
Payment {
|
Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(decode_payment_address(TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap()),
|
recipient_address: RecipientAddress::Sapling(decode_payment_address(TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap()),
|
||||||
amount: NonNegativeAmount::const_from_u64(376876902796286),
|
amount: NonNegativeAmount::const_from_u64(376876902796286),
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -920,7 +920,7 @@ mod tests {
|
||||||
let expected = TransactionRequest {
|
let expected = TransactionRequest {
|
||||||
payments: vec![
|
payments: vec![
|
||||||
Payment {
|
Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(decode_payment_address(TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap()),
|
recipient_address: RecipientAddress::Sapling(decode_payment_address(TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap()),
|
||||||
amount: NonNegativeAmount::ZERO,
|
amount: NonNegativeAmount::ZERO,
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -938,7 +938,7 @@ mod tests {
|
||||||
let req = TransactionRequest {
|
let req = TransactionRequest {
|
||||||
payments: vec![
|
payments: vec![
|
||||||
Payment {
|
Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(decode_payment_address(TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap()),
|
recipient_address: RecipientAddress::Sapling(decode_payment_address(TEST_NETWORK.hrp_sapling_payment_address(), "ztestsapling1n65uaftvs2g7075q2x2a04shfk066u3lldzxsrprfrqtzxnhc9ps73v4lhx4l9yfxj46sl0q90k").unwrap()),
|
||||||
amount: NonNegativeAmount::ZERO,
|
amount: NonNegativeAmount::ZERO,
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
|
|
@ -520,7 +520,7 @@ mod tests {
|
||||||
|
|
||||||
// We can spend the received notes
|
// We can spend the received notes
|
||||||
let req = TransactionRequest::new(vec![Payment {
|
let req = TransactionRequest::new(vec![Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(dfvk.default_address().1),
|
recipient_address: RecipientAddress::Sapling(dfvk.default_address().1),
|
||||||
amount: NonNegativeAmount::const_from_u64(110_000),
|
amount: NonNegativeAmount::const_from_u64(110_000),
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
match decoded {
|
match decoded {
|
||||||
RecipientAddress::Shielded(decoded_address) => {
|
RecipientAddress::Sapling(decoded_address) => {
|
||||||
let dfvk = ufvk.sapling().expect(
|
let dfvk = ufvk.sapling().expect(
|
||||||
"Derivation should have produced a UFVK containing a Sapling component.",
|
"Derivation should have produced a UFVK containing a Sapling component.",
|
||||||
);
|
);
|
||||||
|
@ -97,7 +97,7 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
|
||||||
return Err(WalletMigrationError::CorruptedData(
|
return Err(WalletMigrationError::CorruptedData(
|
||||||
format!("Decoded Sapling address {} does not match the ufvk's Sapling address {} at {:?}.",
|
format!("Decoded Sapling address {} does not match the ufvk's Sapling address {} at {:?}.",
|
||||||
address,
|
address,
|
||||||
RecipientAddress::Shielded(expected_address).encode(&self.params),
|
RecipientAddress::Sapling(expected_address).encode(&self.params),
|
||||||
idx)));
|
idx)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
let output_pool = match decoded_address {
|
let output_pool = match decoded_address {
|
||||||
RecipientAddress::Shielded(_) => {
|
RecipientAddress::Sapling(_) => {
|
||||||
Ok(pool_code(PoolType::Shielded(ShieldedProtocol::Sapling)))
|
Ok(pool_code(PoolType::Shielded(ShieldedProtocol::Sapling)))
|
||||||
}
|
}
|
||||||
RecipientAddress::Transparent(_) => Ok(pool_code(PoolType::Transparent)),
|
RecipientAddress::Transparent(_) => Ok(pool_code(PoolType::Transparent)),
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ pub(crate) mod tests {
|
||||||
let req = TransactionRequest::new(vec![
|
let req = TransactionRequest::new(vec![
|
||||||
// payment to an external recipient
|
// payment to an external recipient
|
||||||
Payment {
|
Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(addr2),
|
recipient_address: RecipientAddress::Sapling(addr2),
|
||||||
amount: amount_sent,
|
amount: amount_sent,
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -1284,7 +1284,7 @@ pub(crate) mod tests {
|
||||||
},
|
},
|
||||||
// payment back to the originating wallet, simulating legacy change
|
// payment back to the originating wallet, simulating legacy change
|
||||||
Payment {
|
Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(addr),
|
recipient_address: RecipientAddress::Sapling(addr),
|
||||||
amount: amount_legacy_change,
|
amount: amount_legacy_change,
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -1398,7 +1398,7 @@ pub(crate) mod tests {
|
||||||
|
|
||||||
// This first request will fail due to insufficient non-dust funds
|
// This first request will fail due to insufficient non-dust funds
|
||||||
let req = TransactionRequest::new(vec![Payment {
|
let req = TransactionRequest::new(vec![Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(dfvk.default_address().1),
|
recipient_address: RecipientAddress::Sapling(dfvk.default_address().1),
|
||||||
amount: NonNegativeAmount::const_from_u64(50000),
|
amount: NonNegativeAmount::const_from_u64(50000),
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -1423,7 +1423,7 @@ pub(crate) mod tests {
|
||||||
// This request will succeed, spending a single dust input to pay the 10000
|
// This request will succeed, spending a single dust input to pay the 10000
|
||||||
// ZAT fee in addition to the 41000 ZAT output to the recipient
|
// ZAT fee in addition to the 41000 ZAT output to the recipient
|
||||||
let req = TransactionRequest::new(vec![Payment {
|
let req = TransactionRequest::new(vec![Payment {
|
||||||
recipient_address: RecipientAddress::Shielded(dfvk.default_address().1),
|
recipient_address: RecipientAddress::Sapling(dfvk.default_address().1),
|
||||||
amount: NonNegativeAmount::const_from_u64(41000),
|
amount: NonNegativeAmount::const_from_u64(41000),
|
||||||
memo: None,
|
memo: None,
|
||||||
label: None,
|
label: None,
|
||||||
|
|
Loading…
Reference in New Issue