bech32 0.8
This commit is contained in:
parent
a0c441817a
commit
c3c7bd1d9c
|
@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0"
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bech32 = "0.7"
|
||||
bech32 = "0.8"
|
||||
bls12_381 = "0.3.1"
|
||||
bs58 = { version = "0.4", features = ["check"] }
|
||||
base64 = "0.13"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//!
|
||||
//! [constants]: zcash_primitives::constants
|
||||
|
||||
use bech32::{self, Error, FromBase32, ToBase32};
|
||||
use bech32::{self, Error, FromBase32, ToBase32, Variant};
|
||||
use bs58::{self, decode::Error as Bs58Error};
|
||||
use std::convert::TryInto;
|
||||
use std::io::{self, Write};
|
||||
|
@ -21,18 +21,18 @@ where
|
|||
{
|
||||
let mut data: Vec<u8> = vec![];
|
||||
write(&mut data).expect("Should be able to write to a Vec");
|
||||
bech32::encode(hrp, data.to_base32()).expect("hrp is invalid")
|
||||
bech32::encode(hrp, data.to_base32(), Variant::Bech32).expect("hrp is invalid")
|
||||
}
|
||||
|
||||
fn bech32_decode<T, F>(hrp: &str, s: &str, read: F) -> Result<Option<T>, Error>
|
||||
where
|
||||
F: Fn(Vec<u8>) -> Option<T>,
|
||||
{
|
||||
let (decoded_hrp, data) = bech32::decode(s)?;
|
||||
if decoded_hrp == hrp {
|
||||
Vec::<u8>::from_base32(&data).map(|data| read(data))
|
||||
} else {
|
||||
Ok(None)
|
||||
match bech32::decode(s)? {
|
||||
(decoded_hrp, data, Variant::Bech32) if decoded_hrp == hrp => {
|
||||
Vec::<u8>::from_base32(&data).map(|data| read(data))
|
||||
}
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0"
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bech32 = "0.7"
|
||||
bech32 = "0.8"
|
||||
bs58 = { version = "0.4", features = ["check"] }
|
||||
ff = "0.8"
|
||||
group = "0.8"
|
||||
|
|
Loading…
Reference in New Issue