Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zcash_client_sqlite: Use consistent criteria for detecting what accounts fund a transaction. #1306

Merged
merged 5 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions zcash_client_backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ and this library adheres to Rust's notion of
feature flag.
- `zcash_client_backend::proto`:
- `ProposalDecodingError` has a new variant `TransparentMemo`.
- `zcash_client_backend::wallet::Recipient::InternalAccount` is now a structured
variant with an additional `external_address` field.
- `zcash_client_backend::zip321::render::amount_str` now takes a
`NonNegativeAmount` rather than a signed `Amount` as its argument.
- `zcash_client_backend::zip321::parse::parse_amount` now parses a
Expand Down
18 changes: 10 additions & 8 deletions zcash_client_backend/src/data_api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,10 +1049,11 @@
memo.clone(),
)?;
sapling_output_meta.push((
Recipient::InternalAccount(
account,
PoolType::Shielded(ShieldedProtocol::Sapling),
),
Recipient::InternalAccount {
receiving_account: account,
external_address: None,
note: PoolType::Shielded(ShieldedProtocol::Sapling),
},
change_value.value(),
Some(memo),
))
Expand All @@ -1072,10 +1073,11 @@
memo.clone(),
)?;
orchard_output_meta.push((
Recipient::InternalAccount(
account,
PoolType::Shielded(ShieldedProtocol::Orchard),
),
Recipient::InternalAccount {
receiving_account: account,
external_address: None,
note: PoolType::Shielded(ShieldedProtocol::Orchard),

Check warning on line 1079 in zcash_client_backend/src/data_api/wallet.rs

View check run for this annotation

Codecov / codecov/patch

zcash_client_backend/src/data_api/wallet.rs#L1076-L1079

Added lines #L1076 - L1079 were not covered by tests
},
change_value.value(),
Some(memo),
))
Expand Down
8 changes: 2 additions & 6 deletions zcash_client_backend/src/decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,8 @@ pub fn decrypt_transaction<'a, P: consensus::Parameters, AccountId: Copy>(
.flat_map(|bundle| {
ufvks
.iter()
.flat_map(move |(account, ufvk)| {
ufvk.orchard()
.into_iter()
.map(|fvk| (account.to_owned(), fvk))
})
.flat_map(move |(account, fvk)| {
.flat_map(|(account, ufvk)| ufvk.orchard().into_iter().map(|fvk| (*account, fvk)))
.flat_map(|(account, fvk)| {
let ivk_external = orchard::keys::PreparedIncomingViewingKey::new(
&fvk.to_ivk(Scope::External),
);
Expand Down
27 changes: 24 additions & 3 deletions zcash_client_backend/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! light client.

use incrementalmerkletree::Position;
use zcash_keys::address::Address;
use zcash_note_encryption::EphemeralKeyBytes;
use zcash_primitives::{
consensus::BlockHeight,
Expand Down Expand Up @@ -70,7 +71,11 @@
Transparent(TransparentAddress),
Sapling(sapling::PaymentAddress),
Unified(UnifiedAddress, PoolType),
InternalAccount(AccountId, N),
InternalAccount {
receiving_account: AccountId,
external_address: Option<Address>,
note: N,
},
}

impl<AccountId, N> Recipient<AccountId, N> {
Expand All @@ -79,7 +84,15 @@
Recipient::Transparent(t) => Recipient::Transparent(t),
Recipient::Sapling(s) => Recipient::Sapling(s),
Recipient::Unified(u, p) => Recipient::Unified(u, p),
Recipient::InternalAccount(a, n) => Recipient::InternalAccount(a, f(n)),
Recipient::InternalAccount {

Check warning on line 87 in zcash_client_backend/src/wallet.rs

View check run for this annotation

Codecov / codecov/patch

zcash_client_backend/src/wallet.rs#L87

Added line #L87 was not covered by tests
receiving_account,
external_address,
note,
} => Recipient::InternalAccount {
receiving_account,
external_address,
note: f(note),
},
}
}
}
Expand All @@ -90,7 +103,15 @@
Recipient::Transparent(t) => Some(Recipient::Transparent(t)),
Recipient::Sapling(s) => Some(Recipient::Sapling(s)),
Recipient::Unified(u, p) => Some(Recipient::Unified(u, p)),
Recipient::InternalAccount(a, n) => n.map(|n0| Recipient::InternalAccount(a, n0)),
Recipient::InternalAccount {

Check warning on line 106 in zcash_client_backend/src/wallet.rs

View check run for this annotation

Codecov / codecov/patch

zcash_client_backend/src/wallet.rs#L106

Added line #L106 was not covered by tests
receiving_account,
external_address,
note,
} => note.map(|n0| Recipient::InternalAccount {
receiving_account,
external_address,
note: n0,
}),
}
}
}
Expand Down
Loading
Loading