returns b58 prefix constants directly to remove From<NetworkKind> impl for zcash_primitives::consensus::Network

This commit is contained in:
Arya 2024-04-01 20:23:55 -04:00
parent d5a807a508
commit d108ec6355
2 changed files with 10 additions and 15 deletions

View File

@ -4,7 +4,7 @@ use std::{fmt, str::FromStr, sync::Arc};
use thiserror::Error;
use zcash_primitives::consensus::{Network as ZcashPrimitivesNetwork, Parameters as _};
use zcash_primitives::constants;
use crate::{
block::{self, Height, HeightDiff},
@ -107,13 +107,19 @@ impl NetworkKind {
/// Returns the human-readable prefix for Base58Check-encoded transparent
/// pay-to-public-key-hash payment addresses for the network.
pub fn b58_pubkey_address_prefix(self) -> [u8; 2] {
<ZcashPrimitivesNetwork>::from(self).b58_pubkey_address_prefix()
match self {
Self::Mainnet => constants::mainnet::B58_PUBKEY_ADDRESS_PREFIX,
Self::Testnet | Self::Regtest => constants::testnet::B58_PUBKEY_ADDRESS_PREFIX,
}
}
/// Returns the human-readable prefix for Base58Check-encoded transparent pay-to-script-hash
/// payment addresses for the network.
pub fn b58_script_address_prefix(self) -> [u8; 2] {
<ZcashPrimitivesNetwork>::from(self).b58_script_address_prefix()
match self {
Self::Mainnet => constants::mainnet::B58_SCRIPT_ADDRESS_PREFIX,
Self::Testnet | Self::Regtest => constants::testnet::B58_SCRIPT_ADDRESS_PREFIX,
}
}
/// Return the network name as defined in

View File

@ -7,7 +7,7 @@ use zcash_primitives::transaction as zp_tx;
use crate::{
amount::{Amount, NonNegative},
parameters::{Network, NetworkKind, NetworkUpgrade, UnsupportedNetwork},
parameters::{Network, NetworkUpgrade, UnsupportedNetwork},
serialization::ZcashSerialize,
transaction::{AuthDigest, HashType, SigHash, Transaction},
transparent::{self, Script},
@ -361,14 +361,3 @@ impl TryFrom<&Network> for zcash_primitives::consensus::Network {
}
}
}
impl From<NetworkKind> for zcash_primitives::consensus::Network {
fn from(network: NetworkKind) -> Self {
match network {
NetworkKind::Mainnet => zcash_primitives::consensus::Network::MainNetwork,
NetworkKind::Testnet | NetworkKind::Regtest => {
zcash_primitives::consensus::Network::TestNetwork
}
}
}
}