Skip to content

Commit

Permalink
Miscellaneous documentation improvements.
Browse files Browse the repository at this point in the history
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
  • Loading branch information
daira committed Jun 18, 2024
1 parent c9c7fa3 commit 9881e81
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 16 deletions.
7 changes: 5 additions & 2 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1514,8 +1514,11 @@ pub trait WalletWrite: WalletRead {
received_tx: DecryptedTransaction<Self::AccountId>,
) -> Result<(), Self::Error>;

/// Saves information about a transaction that was constructed and sent by the wallet to the
/// persistent wallet store.
/// Saves information about a transaction constructed by the wallet to the persistent
/// wallet store.
///
/// The name `store_sent_tx` is somewhat misleading; this must be called *before* the
/// transaction is sent to the network.
fn store_sent_tx(
&mut self,
sent_tx: &SentTransaction<Self::AccountId>,
Expand Down
2 changes: 2 additions & 0 deletions zcash_client_backend/src/data_api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ pub enum Error<DataSourceError, CommitmentTreeError, SelectionError, FeeError> {
/// An error occurred parsing the address from a payment request.
Address(ConversionError<&'static str>),

/// The address associated with a record being inserted was not recognized as
/// belonging to the wallet.
#[cfg(feature = "transparent-inputs")]
AddressNotRecognized(TransparentAddress),
}
Expand Down
12 changes: 6 additions & 6 deletions zcash_client_backend/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,20 @@ impl<NoteRefT> From<BalanceError> for ChangeError<BalanceError, NoteRefT> {
}
}

/// An enumeration of actions to tak when a transaction would potentially create dust
/// outputs (outputs that are likely to be without economic value due to fee rules.)
/// An enumeration of actions to take when a transaction would potentially create dust
/// outputs (outputs that are likely to be without economic value due to fee rules).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DustAction {
/// Do not allow creation of dust outputs; instead, require that additional inputs be provided.
Reject,
/// Explicitly allow the creation of dust change amounts greater than the specified value.
AllowDustChange,
/// Allow dust amounts to be added to the transaction fee
/// Allow dust amounts to be added to the transaction fee.
AddDustToFee,
}

/// A policy describing how a [`ChangeStrategy`] should treat potentially dust-valued change
/// outputs (outputs that are likely to be without economic value due to fee rules.)
/// outputs (outputs that are likely to be without economic value due to fee rules).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct DustOutputPolicy {
action: DustAction,
Expand All @@ -275,7 +275,7 @@ impl DustOutputPolicy {
///
/// A dust policy created with `None` as the dust threshold will delegate determination
/// of the dust threshold to the change strategy that is evaluating the strategy; this
/// recommended, but an explicit value (including zero) may be provided to explicitly
/// is recommended, but an explicit value (including zero) may be provided to explicitly
/// override the determination of the change strategy.
pub fn new(action: DustAction, dust_threshold: Option<NonNegativeAmount>) -> Self {
Self {
Expand All @@ -284,7 +284,7 @@ impl DustOutputPolicy {
}
}

/// Returns the action to take in the event that a dust change amount would be produced
/// Returns the action to take in the event that a dust change amount would be produced.
pub fn action(&self) -> DustAction {
self.action
}
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_backend/src/proto.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Generated code for handling light client protobuf structs.
//! This module contains generated code for handling light client protobuf structs.

use incrementalmerkletree::frontier::CommitmentTree;
use nonempty::NonEmpty;
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_sqlite/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub enum SqliteClientError {
AccountIdOutOfRange,

/// The address associated with a record being inserted was not recognized as
/// belonging to the wallet
/// belonging to the wallet.
#[cfg(feature = "transparent-inputs")]
AddressNotRecognized(TransparentAddress),

Expand Down
2 changes: 1 addition & 1 deletion zcash_keys/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub enum Address {
#[cfg(feature = "sapling")]
Sapling(PaymentAddress),

/// A transparent address corresponding to either a public key or a `Script`.
/// A transparent address corresponding to either a public key hash or a script hash.
Transparent(TransparentAddress),

/// A [ZIP 316] Unified Address.
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl Shl<&[u8]> for Script {
}
}

/// A transparent address corresponding to either a public key or a `Script`.
/// A transparent address corresponding to either a public key hash or a script hash.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum TransparentAddress {
PublicKeyHash([u8; 20]),
Expand Down
8 changes: 6 additions & 2 deletions zcash_primitives/src/transaction/components/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub struct OutPoint {
}

impl OutPoint {
/// Constructs an `OutPoint` for the output at index `n` in the transaction
/// with txid `hash`.
pub fn new(hash: [u8; 32], n: u32) -> Self {
OutPoint { hash, n }
}
Expand All @@ -121,18 +123,20 @@ impl OutPoint {
writer.write_u32::<LittleEndian>(self.n)
}

/// Returns `true` if this `OutPoint` is "null" in the Bitcoin sense: it points to the
/// `u32::MAX`th output of the transaction with the all-zeroes txid.
/// Returns `true` if this `OutPoint` is "null" in the Bitcoin sense: it has txid set to
/// all-zeroes and output index set to `u32::MAX`.
fn is_null(&self) -> bool {
// From `BaseOutPoint::IsNull()` in zcashd:
// return (hash.IsNull() && n == (uint32_t) -1);
self.hash == [0; 32] && self.n == u32::MAX
}

/// Returns the output index of this `OutPoint`.
pub fn n(&self) -> u32 {
self.n
}

/// Returns the txid of the transaction containing this `OutPoint`.
pub fn hash(&self) -> &[u8; 32] {
&self.hash
}
Expand Down
1 change: 1 addition & 0 deletions zcash_primitives/src/transaction/fees/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum InputSize {
}

impl InputSize {
/// An `InputSize` corresponding to the upper bound on the size of a P2PKH input used by ZIP 317.
pub const STANDARD_P2PKH: InputSize = InputSize::Known(P2PKH_STANDARD_INPUT_SIZE);
}

Expand Down
8 changes: 6 additions & 2 deletions zcash_primitives/src/transaction/fees/zip317.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ pub const MINIMUM_FEE: NonNegativeAmount = NonNegativeAmount::const_from_u64(10_
/// A [`FeeRule`] implementation that implements the [ZIP 317] fee rule.
///
/// This fee rule supports Orchard, Sapling, and (P2PKH only) transparent inputs.
/// Returns an error if a coin containing a non-p2pkh script is provided as an input.
/// This fee rule may slightly overestimate fees in case where the user is attempting to spend more than ~150 transparent inputs.
/// Returns an error if a coin containing a non-P2PKH script is provided as an input.
///
/// This fee rule may slightly overestimate fees in case where the user is attempting
/// to spend a large number of transparent inputs. This is intentional and is relied
/// on for the correctness of transaction construction algorithms in the
/// `zcash_client_backend` crate.
///
/// [`FeeRule`]: crate::transaction::fees::FeeRule
/// [ZIP 317]: https//zips.z.cash/zip-0317
Expand Down

0 comments on commit 9881e81

Please sign in to comment.