Skip to content

Commit

Permalink
Address comments from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Apr 22, 2024
1 parent ea82dbe commit aeac544
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
21 changes: 9 additions & 12 deletions components/zcash_address/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,25 +271,22 @@ impl ZcashAddress {

/// Returns whether this address has the ability to receive transfers of the given pool type.
pub fn can_receive_as(&self, pool_type: PoolType) -> bool {
use AddressKind::*;
match &self.kind {
AddressKind::Sprout(_) => false,
AddressKind::Sapling(_) => pool_type == PoolType::Shielded(ShieldedProtocol::Sapling),
AddressKind::Unified(addr) => addr.has_receiver_of_type(pool_type),
AddressKind::P2pkh(_) => pool_type == PoolType::Transparent,
AddressKind::P2sh(_) => pool_type == PoolType::Transparent,
AddressKind::Tex(_) => pool_type == PoolType::Transparent,
Sprout(_) => false,
Sapling(_) => pool_type == PoolType::Shielded(ShieldedProtocol::Sapling),
Unified(addr) => addr.has_receiver_of_type(pool_type),
P2pkh(_) | P2sh(_) | Tex(_) => pool_type == PoolType::Transparent,
}
}

/// Returns whether this address can receive a memo.
pub fn can_receive_memo(&self) -> bool {
use AddressKind::*;
match &self.kind {
AddressKind::Sprout(_) => true,
AddressKind::Sapling(_) => true,
AddressKind::Unified(addr) => addr.can_receive_memo(),
AddressKind::P2pkh(_) => false,
AddressKind::P2sh(_) => false,
AddressKind::Tex(_) => false,
Sprout(_) | Sapling(_) => true,
Unified(addr) => addr.can_receive_memo(),
P2pkh(_) | P2sh(_) | Tex(_) => false,
}
}

Expand Down
12 changes: 12 additions & 0 deletions components/zip321/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,23 @@ pub fn memo_from_base64(s: &str) -> Result<MemoBytes, Zip321Error> {
/// A single payment being requested.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Payment {
/// The address to which the payment should be sent.
recipient_address: ZcashAddress,
/// The amount of the payment that is being requested.
amount: Zatoshis,
/// A memo that, if included, must be provided with the payment.
/// If a memo is present and [`recipient_address`] is not a shielded
/// address, the wallet should report an error.
///
/// [`recipient_address`]: #structfield.recipient_address
memo: Option<MemoBytes>,
/// A human-readable label for this payment within the larger structure
/// of the transaction request.
label: Option<String>,
/// A human-readable message to be displayed to the user describing the
/// purpose of this payment.
message: Option<String>,
/// A list of other arbitrary key/value pairs associated with this payment.
other_params: Vec<(String, String)>,
}

Expand Down
1 change: 0 additions & 1 deletion zcash_client_sqlite/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,6 @@ pub(crate) fn select_receiving_address<P: consensus::Parameters>(
.transpose()
.map_err(SqliteClientError::from),
receiver => {
// at present,
let mut stmt =
conn.prepare_cached("SELECT address FROM addresses WHERE account_id = :account")?;

Expand Down
7 changes: 5 additions & 2 deletions zcash_keys/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ impl UnifiedAddress {
}
}

/// An enumeration of protocol-level receiver types. While these correspond to unified address
/// receiver
/// An enumeration of protocol-level receiver types.
///
/// While these correspond to unified address receiver types, this is a distinct type because it is
/// used to represent the protocol-level recipient of a transfer, instead of a part of an encoded
/// address.
pub enum Receiver {
#[cfg(feature = "orchard")]
Orchard(orchard::Address),
Expand Down

0 comments on commit aeac544

Please sign in to comment.