Skip to content

Commit e097829

Browse files
nuttycomstr4d
andcommitted
Apply suggestions from code review
Co-authored-by: Jack Grigg <[email protected]>
1 parent dbb5eeb commit e097829

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

zcash_client_backend/src/data_api.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -950,14 +950,16 @@ pub trait WalletRead {
950950
address: &TransparentAddress,
951951
) -> Result<Option<TransparentAddressMetadata>, Self::Error> {
952952
// This should be overridden.
953-
if let Some(result) = self.get_transparent_receivers(account)?.get(address) {
954-
return Ok(result.clone());
955-
}
956-
Ok(self
957-
.get_known_ephemeral_addresses(account, None)?
958-
.into_iter()
959-
.find(|(known_addr, _)| known_addr == address)
960-
.map(|(_, metadata)| metadata))
953+
Ok(
954+
if let Some(result) = self.get_transparent_receivers(account)?.get(address) {
955+
result.clone()
956+
} else {
957+
self.get_known_ephemeral_addresses(account, None)?
958+
.into_iter()
959+
.find(|(known_addr, _)| known_addr == address)
960+
.map(|(_, metadata)| metadata)
961+
},
962+
)
961963
}
962964

963965
/// Returns a vector of ephemeral transparent addresses associated with the given
@@ -1001,7 +1003,7 @@ pub trait WalletRead {
10011003
Ok(vec![])
10021004
}
10031005

1004-
/// If a given transparent address has been reserved, i.e. would be included in
1006+
/// If a given ephemeral address might have been reserved, i.e. would be included in
10051007
/// the map returned by `get_known_ephemeral_addresses(account_id, false)` for any
10061008
/// of the wallet's accounts, then return `Ok(Some(account_id))`. Otherwise return
10071009
/// `Ok(None)`.

zcash_client_backend/src/data_api/wallet/input_selection.rs

+3
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ where
384384
let mut tr1_payments = vec![];
385385
#[cfg(feature = "transparent-inputs")]
386386
let mut tr1_payment_pools = BTreeMap::new();
387+
// this balance value is just used for overflow checking; the actual value of ephemeral
388+
// outputs will be computed from the constructed `tr1_transparent_outputs` value
389+
// constructed below.
387390
#[cfg(feature = "transparent-inputs")]
388391
let mut total_ephemeral = NonNegativeAmount::ZERO;
389392

zcash_client_sqlite/src/wallet/transparent/ephemeral.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub(crate) fn find_index_for_ephemeral_address_str(
187187
Ok(conn
188188
.query_row(
189189
"SELECT address_index FROM ephemeral_addresses
190-
WHERE account_id = :account_id AND address = :address",
190+
WHERE account_id = :account_id AND address = :address",
191191
named_params![":account_id": account_id.0, ":address": &address_str],
192192
|row| row.get::<_, u32>(0),
193193
)

zcash_primitives/src/legacy/keys.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ use super::TransparentAddress;
2121
pub struct TransparentKeyScope(u32);
2222

2323
impl TransparentKeyScope {
24-
/// Returns an arbitrary custom `TransparentKeyScope`. This should be used
25-
/// with care: funds associated with keys derived under a custom scope may
26-
/// not be recoverable if the wallet seed is restored in another wallet.
27-
/// It is usually preferable to use standardized key scopes.
24+
/// Returns an arbitrary custom `TransparentKeyScope`.
25+
///
26+
/// This should be used with care: funds associated with keys derived under a custom
27+
/// scope may not be recoverable if the wallet seed is restored in another wallet. It
28+
/// is usually preferable to use standardized key scopes.
2829
pub const fn custom(i: u32) -> Option<Self> {
2930
if i < (1 << 31) {
3031
Some(TransparentKeyScope(i))

0 commit comments

Comments
 (0)