zcash_client_backend: Rename `RecipientAddress::Shielded` to `RecipientAddress::Sapling`

This commit is contained in:
Kris Nuttycombe 2023-12-07 15:24:47 -07:00
parent ecd5402266
commit aab9938b53
8 changed files with 22 additions and 19 deletions

View File

@ -181,6 +181,9 @@ and this library adheres to Rust's notion of
- `ReceivedSaplingNote::value`
- `WalletTransparentOutput::value`
- `zcash_client_backend::address`:
- `RecipientAddress::Shielded` has been renamed to `RecipientAddress::Sapling`
### Removed
- `zcash_client_backend::wallet::ReceivedSaplingNote` has been replaced by
`zcash_client_backend::ReceivedNote`.

View File

@ -176,14 +176,14 @@ impl UnifiedAddress {
// TODO: rename to ParsedAddress
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum RecipientAddress {
Shielded(PaymentAddress),
Sapling(PaymentAddress),
Transparent(TransparentAddress),
Unified(UnifiedAddress),
}
impl From<PaymentAddress> for RecipientAddress {
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");
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 {
TransparentAddress::PublicKey(data) => {
ZcashAddress::from_transparent_p2pkh(net, *data)

View File

@ -679,7 +679,7 @@ where
)));
}
}
RecipientAddress::Shielded(addr) => {
RecipientAddress::Sapling(addr) => {
let memo = payment
.memo
.as_ref()

View File

@ -513,7 +513,7 @@ where
RecipientAddress::Transparent(addr) => {
push_transparent(*addr);
}
RecipientAddress::Shielded(_) => {
RecipientAddress::Sapling(_) => {
push_sapling();
}
RecipientAddress::Unified(addr) => {

View File

@ -554,7 +554,7 @@ mod parse {
match v {
Param::Amount(a) => payment.amount = a,
Param::Memo(m) => match payment.recipient_address {
RecipientAddress::Shielded(_) | RecipientAddress::Unified(_) => {
RecipientAddress::Sapling(_) | RecipientAddress::Unified(_) => {
payment.memo = Some(m)
}
RecipientAddress::Transparent(_) => {
@ -770,7 +770,7 @@ pub mod testing {
pub fn arb_addr() -> impl Strategy<Value = RecipientAddress> {
prop_oneof![
arb_payment_address().prop_map(RecipientAddress::Shielded),
arb_payment_address().prop_map(RecipientAddress::Sapling),
arb_transparent_addr().prop_map(RecipientAddress::Transparent),
arb_unified_addr().prop_map(RecipientAddress::Unified),
]
@ -797,7 +797,7 @@ pub mod testing {
let is_shielded = match recipient_address {
RecipientAddress::Transparent(_) => false,
RecipientAddress::Shielded(_) | RecipientAddress::Unified(_) => true,
RecipientAddress::Sapling(_) | RecipientAddress::Unified(_) => true,
};
Payment {
@ -899,7 +899,7 @@ mod tests {
let expected = TransactionRequest {
payments: vec![
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),
memo: None,
label: None,
@ -920,7 +920,7 @@ mod tests {
let expected = TransactionRequest {
payments: vec![
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,
memo: None,
label: None,
@ -938,7 +938,7 @@ mod tests {
let req = TransactionRequest {
payments: vec![
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,
memo: None,
label: None,

View File

@ -520,7 +520,7 @@ mod tests {
// We can spend the received notes
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),
memo: None,
label: None,

View File

@ -88,7 +88,7 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
))
})?;
match decoded {
RecipientAddress::Shielded(decoded_address) => {
RecipientAddress::Sapling(decoded_address) => {
let dfvk = ufvk.sapling().expect(
"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(
format!("Decoded Sapling address {} does not match the ufvk's Sapling address {} at {:?}.",
address,
RecipientAddress::Shielded(expected_address).encode(&self.params),
RecipientAddress::Sapling(expected_address).encode(&self.params),
idx)));
}
}
@ -226,7 +226,7 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
))
})?;
let output_pool = match decoded_address {
RecipientAddress::Shielded(_) => {
RecipientAddress::Sapling(_) => {
Ok(pool_code(PoolType::Shielded(ShieldedProtocol::Sapling)))
}
RecipientAddress::Transparent(_) => Ok(pool_code(PoolType::Transparent)),

View File

@ -1275,7 +1275,7 @@ pub(crate) mod tests {
let req = TransactionRequest::new(vec![
// payment to an external recipient
Payment {
recipient_address: RecipientAddress::Shielded(addr2),
recipient_address: RecipientAddress::Sapling(addr2),
amount: amount_sent,
memo: None,
label: None,
@ -1284,7 +1284,7 @@ pub(crate) mod tests {
},
// payment back to the originating wallet, simulating legacy change
Payment {
recipient_address: RecipientAddress::Shielded(addr),
recipient_address: RecipientAddress::Sapling(addr),
amount: amount_legacy_change,
memo: None,
label: None,
@ -1398,7 +1398,7 @@ pub(crate) mod tests {
// This first request will fail due to insufficient non-dust funds
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),
memo: None,
label: None,
@ -1423,7 +1423,7 @@ pub(crate) mod tests {
// 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
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),
memo: None,
label: None,