Address comments from code review.
This commit is contained in:
parent
ea82dbeb64
commit
aeac544aed
|
@ -271,25 +271,22 @@ impl ZcashAddress {
|
||||||
|
|
||||||
/// Returns whether this address has the ability to receive transfers of the given pool type.
|
/// 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 {
|
pub fn can_receive_as(&self, pool_type: PoolType) -> bool {
|
||||||
|
use AddressKind::*;
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
AddressKind::Sprout(_) => false,
|
Sprout(_) => false,
|
||||||
AddressKind::Sapling(_) => pool_type == PoolType::Shielded(ShieldedProtocol::Sapling),
|
Sapling(_) => pool_type == PoolType::Shielded(ShieldedProtocol::Sapling),
|
||||||
AddressKind::Unified(addr) => addr.has_receiver_of_type(pool_type),
|
Unified(addr) => addr.has_receiver_of_type(pool_type),
|
||||||
AddressKind::P2pkh(_) => pool_type == PoolType::Transparent,
|
P2pkh(_) | P2sh(_) | Tex(_) => pool_type == PoolType::Transparent,
|
||||||
AddressKind::P2sh(_) => pool_type == PoolType::Transparent,
|
|
||||||
AddressKind::Tex(_) => pool_type == PoolType::Transparent,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether this address can receive a memo.
|
/// Returns whether this address can receive a memo.
|
||||||
pub fn can_receive_memo(&self) -> bool {
|
pub fn can_receive_memo(&self) -> bool {
|
||||||
|
use AddressKind::*;
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
AddressKind::Sprout(_) => true,
|
Sprout(_) | Sapling(_) => true,
|
||||||
AddressKind::Sapling(_) => true,
|
Unified(addr) => addr.can_receive_memo(),
|
||||||
AddressKind::Unified(addr) => addr.can_receive_memo(),
|
P2pkh(_) | P2sh(_) | Tex(_) => false,
|
||||||
AddressKind::P2pkh(_) => false,
|
|
||||||
AddressKind::P2sh(_) => false,
|
|
||||||
AddressKind::Tex(_) => false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,11 +116,23 @@ pub fn memo_from_base64(s: &str) -> Result<MemoBytes, Zip321Error> {
|
||||||
/// A single payment being requested.
|
/// A single payment being requested.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Payment {
|
pub struct Payment {
|
||||||
|
/// The address to which the payment should be sent.
|
||||||
recipient_address: ZcashAddress,
|
recipient_address: ZcashAddress,
|
||||||
|
/// The amount of the payment that is being requested.
|
||||||
amount: Zatoshis,
|
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>,
|
memo: Option<MemoBytes>,
|
||||||
|
/// A human-readable label for this payment within the larger structure
|
||||||
|
/// of the transaction request.
|
||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
|
/// A human-readable message to be displayed to the user describing the
|
||||||
|
/// purpose of this payment.
|
||||||
message: Option<String>,
|
message: Option<String>,
|
||||||
|
/// A list of other arbitrary key/value pairs associated with this payment.
|
||||||
other_params: Vec<(String, String)>,
|
other_params: Vec<(String, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2395,7 +2395,6 @@ pub(crate) fn select_receiving_address<P: consensus::Parameters>(
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(SqliteClientError::from),
|
.map_err(SqliteClientError::from),
|
||||||
receiver => {
|
receiver => {
|
||||||
// at present,
|
|
||||||
let mut stmt =
|
let mut stmt =
|
||||||
conn.prepare_cached("SELECT address FROM addresses WHERE account_id = :account")?;
|
conn.prepare_cached("SELECT address FROM addresses WHERE account_id = :account")?;
|
||||||
|
|
||||||
|
|
|
@ -233,8 +233,11 @@ impl UnifiedAddress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An enumeration of protocol-level receiver types. While these correspond to unified address
|
/// An enumeration of protocol-level receiver types.
|
||||||
/// receiver
|
///
|
||||||
|
/// 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 {
|
pub enum Receiver {
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
Orchard(orchard::Address),
|
Orchard(orchard::Address),
|
||||||
|
|
Loading…
Reference in New Issue