From 0fd88096daf395f6b94f63eefb5b5c9962d50799 Mon Sep 17 00:00:00 2001 From: gruve-p Date: Mon, 12 Feb 2024 14:08:12 +0100 Subject: [PATCH] Use bech32grs --- Cargo-minimal.lock | 7 ++++--- Cargo-recent.lock | 7 ++++--- groestlcoin/Cargo.toml | 6 +++--- groestlcoin/src/address/error.rs | 6 +++--- groestlcoin/src/address/mod.rs | 8 ++++---- groestlcoin/src/blockdata/script/witness_version.rs | 4 ++-- groestlcoin/src/lib.rs | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index c9762e5a50..0f37c7d689 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -15,9 +15,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] -name = "bech32" +name = "bech32grs" version = "0.10.0-beta" -source = "git+https://github.com/Groestlcoin/rust-bech32#7fa28249c554c52bb7a14257d91109a8652b9dd6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e190aad8fbe17cf8d2d68ba93844c33a2ef9544e05945da83df0bf81078f044" [[package]] name = "bincode" @@ -126,7 +127,7 @@ name = "groestlcoin" version = "0.31.0" dependencies = [ "base64", - "bech32", + "bech32grs", "bincode", "core2", "groestlcoin-internals", diff --git a/Cargo-recent.lock b/Cargo-recent.lock index 1e2adfb8f7..5e810b0778 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -15,9 +15,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] -name = "bech32" +name = "bech32grs" version = "0.10.0-beta" -source = "git+https://github.com/Groestlcoin/rust-bech32#7fa28249c554c52bb7a14257d91109a8652b9dd6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e190aad8fbe17cf8d2d68ba93844c33a2ef9544e05945da83df0bf81078f044" [[package]] name = "bincode" @@ -125,7 +126,7 @@ name = "groestlcoin" version = "0.31.0" dependencies = [ "base64", - "bech32", + "bech32grs", "bincode", "core2", "groestlcoin-internals", diff --git a/groestlcoin/Cargo.toml b/groestlcoin/Cargo.toml index c29f8abe16..ba42d8da1f 100644 --- a/groestlcoin/Cargo.toml +++ b/groestlcoin/Cargo.toml @@ -26,8 +26,8 @@ groestlcoinconsensus-std = ["groestlcoinconsensus/std", "std"] # The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. # Instead no-std enables additional features required for this crate to be usable without std. # As a result, both can be enabled without conflict. -std = ["secp256k1/std", "hashes/std", "bech32/std", "internals/std", "hex/std"] -no-std = ["core2", "hashes/alloc", "hashes/core2", "bech32/alloc", "secp256k1/alloc", "hex/alloc", "hex/core2"] +std = ["secp256k1/std", "hashes/std", "bech32grs/std", "internals/std", "hex/std"] +no-std = ["core2", "hashes/alloc", "hashes/core2", "bech32grs/alloc", "secp256k1/alloc", "hex/alloc", "hex/core2"] [package.metadata.docs.rs] all-features = true @@ -36,7 +36,7 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] internals = { package = "groestlcoin-internals", version = "0.2.0" } hex = { package = "hex-conservative", version = "0.1.1", default-features = false } -bech32 = { git = "https://github.com/Groestlcoin/rust-bech32", default-features = false } +bech32grs = { version = "0.10.0-beta", default-features = false } hashes = { package = "groestlcoin_hashes", version = "0.13.0", default-features = false } secp256k1 = { version = "0.28.0", default-features = false } # do not use bitcoin-hashes feature hex_lit = "0.1.1" diff --git a/groestlcoin/src/address/error.rs b/groestlcoin/src/address/error.rs index fb65b85637..ced8d73130 100644 --- a/groestlcoin/src/address/error.rs +++ b/groestlcoin/src/address/error.rs @@ -103,7 +103,7 @@ pub enum ParseError { /// Base58 error. Base58(base58::Error), /// Bech32 segwit decoding error. - Bech32(bech32::segwit::DecodeError), + Bech32(bech32grs::segwit::DecodeError), /// A witness version conversion/parsing error. WitnessVersion(witness_version::TryFromError), /// A witness program error. @@ -141,8 +141,8 @@ impl From for ParseError { fn from(e: base58::Error) -> Self { Self::Base58(e) } } -impl From for ParseError { - fn from(e: bech32::segwit::DecodeError) -> Self { Self::Bech32(e) } +impl From for ParseError { + fn from(e: bech32grs::segwit::DecodeError) -> Self { Self::Bech32(e) } } impl From for ParseError { diff --git a/groestlcoin/src/address/mod.rs b/groestlcoin/src/address/mod.rs index 28f78c59c4..ac1b6a8f45 100644 --- a/groestlcoin/src/address/mod.rs +++ b/groestlcoin/src/address/mod.rs @@ -31,7 +31,7 @@ use core::fmt; use core::marker::PhantomData; use core::str::FromStr; -use bech32::primitives::hrp::{self, Hrp}; +use bech32grs::primitives::hrp::{self, Hrp}; use hashes::{sha256, Hash, HashEngine}; use secp256k1::{Secp256k1, Verification, XOnlyPublicKey}; @@ -264,9 +264,9 @@ impl<'a> fmt::Display for AddressEncoding<'a> { let program = witness_program.program().as_bytes(); if fmt.alternate() { - bech32::segwit::encode_upper_to_fmt_unchecked(fmt, hrp, version, program) + bech32grs::segwit::encode_upper_to_fmt_unchecked(fmt, hrp, version, program) } else { - bech32::segwit::encode_lower_to_fmt_unchecked(fmt, hrp, version, program) + bech32grs::segwit::encode_lower_to_fmt_unchecked(fmt, hrp, version, program) } } } @@ -798,7 +798,7 @@ impl FromStr for Address { _ => None, }; if let Some(network) = bech32_network { - let (_hrp, version, data) = bech32::segwit::decode(s)?; + let (_hrp, version, data) = bech32grs::segwit::decode(s)?; let version = WitnessVersion::try_from(version).expect("we know this is in range 0-16"); let program = PushBytesBuf::try_from(data).expect("decode() guarantees valid length"); let witness_program = WitnessProgram::new(version, program)?; diff --git a/groestlcoin/src/blockdata/script/witness_version.rs b/groestlcoin/src/blockdata/script/witness_version.rs index cf9334324f..2ea08b7094 100644 --- a/groestlcoin/src/blockdata/script/witness_version.rs +++ b/groestlcoin/src/blockdata/script/witness_version.rs @@ -11,7 +11,7 @@ use core::convert::TryFrom; use core::fmt; use core::str::FromStr; -use bech32::Fe32; +use bech32grs::Fe32; use internals::write_err; use crate::blockdata::opcodes::all::*; @@ -93,7 +93,7 @@ impl FromStr for WitnessVersion { } } -impl TryFrom for WitnessVersion { +impl TryFrom for WitnessVersion { type Error = TryFromError; fn try_from(value: Fe32) -> Result { Self::try_from(value.to_u8()) } diff --git a/groestlcoin/src/lib.rs b/groestlcoin/src/lib.rs index a8d79117d8..e7bdaff092 100644 --- a/groestlcoin/src/lib.rs +++ b/groestlcoin/src/lib.rs @@ -62,7 +62,7 @@ extern crate alloc; pub extern crate base64; /// Encodes and decodes the Bech32 forrmat. -pub extern crate bech32; +pub extern crate bech32grs; #[cfg(feature = "groestlcoinconsensus")] /// Groestlcoin's libgroestlcoinconsensus with Rust binding.