diff --git a/zebra-chain/src/sapling/address.rs b/zebra-chain/src/sapling/address.rs index 2ee9e6ae5..693746086 100644 --- a/zebra-chain/src/sapling/address.rs +++ b/zebra-chain/src/sapling/address.rs @@ -5,7 +5,7 @@ use std::{ io::{self, Read, Write}, }; -use bech32::{self, FromBase32, ToBase32}; +use bech32::{self, FromBase32, ToBase32, Variant}; #[cfg(test)] use proptest::prelude::*; @@ -58,7 +58,7 @@ impl fmt::Display for Address { _ => human_readable_parts::TESTNET, }; - bech32::encode_to_fmt(f, hrp, bytes.get_ref().to_base32()).unwrap() + bech32::encode_to_fmt(f, hrp, bytes.get_ref().to_base32(), Variant::Bech32).unwrap() } } @@ -67,7 +67,7 @@ impl std::str::FromStr for Address { fn from_str(s: &str) -> Result { match bech32::decode(s) { - Ok((hrp, bytes)) => { + Ok((hrp, bytes, Variant::Bech32)) => { let mut decoded_bytes = io::Cursor::new(Vec::::from_base32(&bytes).unwrap()); let mut diversifier_bytes = [0; 11]; @@ -84,7 +84,7 @@ impl std::str::FromStr for Address { transmission_key: keys::TransmissionKey::from(transmission_key_bytes), }) } - Err(_) => Err(SerializationError::Parse("bech32 decoding error")), + _ => Err(SerializationError::Parse("bech32 decoding error")), } } } diff --git a/zebra-chain/src/sapling/keys.rs b/zebra-chain/src/sapling/keys.rs index ef274d6d3..41f0ec0eb 100644 --- a/zebra-chain/src/sapling/keys.rs +++ b/zebra-chain/src/sapling/keys.rs @@ -21,7 +21,7 @@ use std::{ str::FromStr, }; -use bech32::{self, FromBase32, ToBase32}; +use bech32::{self, FromBase32, ToBase32, Variant}; use rand_core::{CryptoRng, RngCore}; use crate::{ @@ -206,7 +206,7 @@ impl fmt::Display for SpendingKey { _ => sk_hrp::TESTNET, }; - bech32::encode_to_fmt(f, hrp, &self.bytes.to_base32()).unwrap() + bech32::encode_to_fmt(f, hrp, &self.bytes.to_base32(), Variant::Bech32).unwrap() } } @@ -215,7 +215,7 @@ impl FromStr for SpendingKey { fn from_str(s: &str) -> Result { match bech32::decode(s) { - Ok((hrp, bytes)) => { + Ok((hrp, bytes, Variant::Bech32)) => { let decoded = Vec::::from_base32(&bytes).unwrap(); let mut decoded_bytes = [0u8; 32]; @@ -229,7 +229,7 @@ impl FromStr for SpendingKey { bytes: decoded_bytes, }) } - Err(_) => Err(SerializationError::Parse("bech32 decoding error")), + _ => Err(SerializationError::Parse("bech32 decoding error")), } } } @@ -527,7 +527,7 @@ impl fmt::Display for IncomingViewingKey { _ => ivk_hrp::TESTNET, }; - bech32::encode_to_fmt(f, hrp, &self.scalar.to_bytes().to_base32()).unwrap() + bech32::encode_to_fmt(f, hrp, &self.scalar.to_bytes().to_base32(), Variant::Bech32).unwrap() } } @@ -576,7 +576,7 @@ impl FromStr for IncomingViewingKey { fn from_str(s: &str) -> Result { match bech32::decode(s) { - Ok((hrp, bytes)) => { + Ok((hrp, bytes, Variant::Bech32)) => { let decoded = Vec::::from_base32(&bytes).unwrap(); let mut scalar_bytes = [0u8; 32]; @@ -590,7 +590,7 @@ impl FromStr for IncomingViewingKey { scalar: Scalar::from_bytes(&scalar_bytes).unwrap(), }) } - Err(_) => Err(SerializationError::Parse("bech32 decoding error")), + _ => Err(SerializationError::Parse("bech32 decoding error")), } } } @@ -833,7 +833,7 @@ impl fmt::Display for FullViewingKey { _ => fvk_hrp::TESTNET, }; - bech32::encode_to_fmt(f, hrp, bytes.get_ref().to_base32()).unwrap() + bech32::encode_to_fmt(f, hrp, bytes.get_ref().to_base32(), Variant::Bech32).unwrap() } } @@ -842,7 +842,7 @@ impl FromStr for FullViewingKey { fn from_str(s: &str) -> Result { match bech32::decode(s) { - Ok((hrp, bytes)) => { + Ok((hrp, bytes, Variant::Bech32)) => { let mut decoded_bytes = io::Cursor::new(Vec::::from_base32(&bytes).unwrap()); let authorizing_key_bytes = decoded_bytes.read_32_bytes()?; @@ -861,7 +861,7 @@ impl FromStr for FullViewingKey { outgoing_viewing_key: OutgoingViewingKey::from(outgoing_key_bytes), }) } - Err(_) => Err(SerializationError::Parse("bech32 decoding error")), + _ => Err(SerializationError::Parse("bech32 decoding error")), } } }