Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Mar 5, 2024
1 parent 38af3a4 commit 9f632ea
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion components/zcash_protocol/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Electric Coin Company
Copyright (c) 2021-2024 Electric Coin Company

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 9 additions & 9 deletions components/zcash_protocol/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::convert::TryFrom;
use std::fmt;
use std::ops::{Add, Bound, RangeBounds, Sub};

use crate::constants::{self, mainnet, regtest, testnet};
use crate::constants::{mainnet, regtest, testnet};

#[cfg(feature = "local-consensus")]
use crate::local_consensus::LocalNetwork;
Expand Down Expand Up @@ -216,7 +216,7 @@ impl NetworkConstants for NetworkType {
match self {
NetworkType::Main => mainnet::COIN_TYPE,
NetworkType::Test => testnet::COIN_TYPE,
NetworkType::Regtest => testnet::COIN_TYPE,
NetworkType::Regtest => regtest::COIN_TYPE,
}
}

Expand Down Expand Up @@ -246,24 +246,24 @@ impl NetworkConstants for NetworkType {

fn b58_sprout_address_prefix(&self) -> [u8; 2] {
match self {
NetworkType::Main => constants::mainnet::B58_SPROUT_ADDRESS_PREFIX,
NetworkType::Test => constants::testnet::B58_SPROUT_ADDRESS_PREFIX,
NetworkType::Regtest => testnet::B58_SPROUT_ADDRESS_PREFIX,
NetworkType::Main => mainnet::B58_SPROUT_ADDRESS_PREFIX,
NetworkType::Test => testnet::B58_SPROUT_ADDRESS_PREFIX,
NetworkType::Regtest => regtest::B58_SPROUT_ADDRESS_PREFIX,
}
}

fn b58_pubkey_address_prefix(&self) -> [u8; 2] {
match self {
NetworkType::Main => constants::mainnet::B58_PUBKEY_ADDRESS_PREFIX,
NetworkType::Test => constants::testnet::B58_PUBKEY_ADDRESS_PREFIX,
NetworkType::Main => mainnet::B58_PUBKEY_ADDRESS_PREFIX,
NetworkType::Test => testnet::B58_PUBKEY_ADDRESS_PREFIX,
NetworkType::Regtest => regtest::B58_PUBKEY_ADDRESS_PREFIX,
}
}

fn b58_script_address_prefix(&self) -> [u8; 2] {
match self {
NetworkType::Main => constants::mainnet::B58_SCRIPT_ADDRESS_PREFIX,
NetworkType::Test => constants::testnet::B58_SCRIPT_ADDRESS_PREFIX,
NetworkType::Main => mainnet::B58_SCRIPT_ADDRESS_PREFIX,
NetworkType::Test => testnet::B58_SCRIPT_ADDRESS_PREFIX,
NetworkType::Regtest => regtest::B58_SCRIPT_ADDRESS_PREFIX,
}
}
Expand Down
8 changes: 8 additions & 0 deletions components/zcash_protocol/src/constants/regtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ pub const HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY: &str = "zxviewregtestsapling";
/// [the `zcashd` codebase]: <https://github.com/zcash/zcash/blob/128d863fb8be39ee294fda397c1ce3ba3b889cb2/src/chainparams.cpp#L493>
pub const HRP_SAPLING_PAYMENT_ADDRESS: &str = "zregtestsapling";

/// The prefix for a Base58Check-encoded regtest Sprout addresses.
///
/// Defined in the [Zcash Protocol Specification section 5.6.3][sproutpaymentaddrencoding].
/// As is specified, this is identical to the testnet prefix.
///
/// [sproutpaymentaddrencoding]: https://zips.z.cash/protocol/protocol.pdf#sproutpaymentaddrencoding
pub const B58_SPROUT_ADDRESS_PREFIX: [u8; 2] = [0x16, 0xb6];

/// The prefix for a Base58Check-encoded regtest transparent [`PublicKeyHash`].
/// Same as the testnet prefix.
///
Expand Down
2 changes: 1 addition & 1 deletion components/zcash_protocol/src/constants/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub const HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY: &str = "zxviewtestsapling";
/// [Zcash Protocol Specification]: https://github.com/zcash/zips/blob/master/protocol/protocol.pdf
pub const HRP_SAPLING_PAYMENT_ADDRESS: &str = "ztestsapling";

/// The prefix for a Base58Check-encoded testnet Sprout address
/// The prefix for a Base58Check-encoded testnet Sprout addresses.
///
/// Defined in the [Zcash Protocol Specification section 5.6.3][sproutpaymentaddrencoding].
///
Expand Down
2 changes: 2 additions & 0 deletions zcash_primitives/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ and this library adheres to Rust's notion of
- `impl From<NonNegativeAmount> for sapling::value::NoteValue`
- `impl TryFrom<orchard::ValueSum> for Amount`
- `impl From<NonNegativeAmount> for orchard::NoteValue`
- The `local_consensus` module has been removed; use it from the `zcash_protocol`
module instead.

## [0.14.0] - 2024-03-01
### Added
Expand Down

0 comments on commit 9f632ea

Please sign in to comment.