diff --git a/components/zcash_address/src/encoding.rs b/components/zcash_address/src/encoding.rs index d4d12a7830..a47b1ac972 100644 --- a/components/zcash_address/src/encoding.rs +++ b/components/zcash_address/src/encoding.rs @@ -90,6 +90,7 @@ impl FromStr for ZcashAddress { let net = match hrp.as_str() { tex::MAINNET => Network::Main, tex::TESTNET => Network::Test, + tex::REGTEST => Network::Regtest, // Not recognized as a Zcash address type _ => { return Err(ParseError::NotZcash); @@ -179,7 +180,8 @@ impl fmt::Display for ZcashAddress { AddressKind::Tex(data) => encode_bech32( match self.net { Network::Main => tex::MAINNET, - Network::Test | Network::Regtest => tex::TESTNET, + Network::Test => tex::TESTNET, + Network::Regtest => tex::REGTEST, }, data, Variant::Bech32m, diff --git a/components/zcash_address/src/kind/tex.rs b/components/zcash_address/src/kind/tex.rs index b815f2b92b..f84d427df7 100644 --- a/components/zcash_address/src/kind/tex.rs +++ b/components/zcash_address/src/kind/tex.rs @@ -1,7 +1,11 @@ -/// The prefix for a Base58Check-encoded mainnet transparent +/// The prefix for a Bech32m-encoded mainnet transparent /// [ZIP 320](https://zips.z.cash/zip-0320.html) TEX address. pub(crate) const MAINNET: &str = "tex"; -/// The prefix for a Base58Check-encoded testnet transparent +/// The prefix for a Bech32m-encoded testnet transparent /// [ZIP 320](https://zips.z.cash/zip-0320.html) TEX address. pub(crate) const TESTNET: &str = "textest"; + +/// The prefix for a Bech32m-encoded regtest transparent +/// [ZIP 320](https://zips.z.cash/zip-0320.html) TEX address. +pub(crate) const REGTEST: &str = "texregtest"; diff --git a/components/zcash_address/src/kind/unified.rs b/components/zcash_address/src/kind/unified.rs index cc5b44c6fd..8d70423250 100644 --- a/components/zcash_address/src/kind/unified.rs +++ b/components/zcash_address/src/kind/unified.rs @@ -505,6 +505,9 @@ pub(crate) mod private { length ))); } + // The "as usize" casts cannot change the values, because both + // cursor.position() and addr_end are u64 values <= buf.len() + // which is usize. let data = &buf[cursor.position() as usize..addr_end as usize]; let result = match Typecode::try_from(typecode)? { Typecode::Data(tc) => Item::Data(R::parse(tc, data)?),