Merge rust-bitcoin/rust-bitcoin#2932: Remove `bech32` dependency from `blockdata`

010141ecc9 api: Run just check-api (Tobin C. Harding)
cf800a1b07 Remove bech32 dependency from blockdata (Tobin C. Harding)

Pull request description:

  We have a single usage of the `bech32` crate inside the `blockdata` module, to convert a `WitnessVersion` to a `Fe32`. We then have a single call site where we use the conversion in the `address` module.

  This code was written without thinking to hard about the introduced dependency on `bech32`, in hindsite it shouldn't have been added.

  In preparation for splitting a bunch of code in `blockdata` out into the `primitives` crate remove the `bech32` stuff from the `witness_version` module.

ACKs for top commit:
  Kixunil:
    ACK 010141ecc9
  apoelstra:
    ACK 010141ecc9

Tree-SHA512: 2d368ebf64ab7197b421e0dec48623f3fb03243081a988ff9ed2070135c8741efe24520c2aab496d54c52595808f10ee39816eaab8e3e4a7e64955cd25285670
This commit is contained in:
merge-script 2024-06-29 12:51:45 +00:00
commit 35202ba51b
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
5 changed files with 4 additions and 33 deletions

View File

@ -1854,7 +1854,6 @@ impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromErr
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::address::error::ParseError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::address::error::ParseError
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::FromStrError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::FromStrError
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::TryFromInstructionError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::TryFromInstructionError
impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bech32::primitives::gf32::Fe32
impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bitcoin::blockdata::opcodes::Opcode impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bitcoin::blockdata::opcodes::Opcode
impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::InputsIndexError impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::InputsIndexError
impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::OutputsIndexError impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::OutputsIndexError
@ -2009,7 +2008,6 @@ impl core::convert::TryFrom<alloc::string::String> for bitcoin::blockdata::trans
impl core::convert::TryFrom<alloc::string::String> for bitcoin::p2p::message::CommandString impl core::convert::TryFrom<alloc::string::String> for bitcoin::p2p::message::CommandString
impl core::convert::TryFrom<alloc::vec::Vec<bitcoin::taproot::TapNodeHash>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch impl core::convert::TryFrom<alloc::vec::Vec<bitcoin::taproot::TapNodeHash>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch
impl core::convert::TryFrom<alloc::vec::Vec<u8>> for bitcoin::blockdata::script::PushBytesBuf impl core::convert::TryFrom<alloc::vec::Vec<u8>> for bitcoin::blockdata::script::PushBytesBuf
impl core::convert::TryFrom<bech32::primitives::gf32::Fe32> for bitcoin::blockdata::script::witness_version::WitnessVersion
impl core::convert::TryFrom<bitcoin::PublicKey> for bitcoin::CompressedPublicKey impl core::convert::TryFrom<bitcoin::PublicKey> for bitcoin::CompressedPublicKey
impl core::convert::TryFrom<bitcoin::blockdata::constants::ChainHash> for bitcoin::network::Network impl core::convert::TryFrom<bitcoin::blockdata::constants::ChainHash> for bitcoin::network::Network
impl core::convert::TryFrom<bitcoin::blockdata::opcodes::Opcode> for bitcoin::blockdata::script::witness_version::WitnessVersion impl core::convert::TryFrom<bitcoin::blockdata::opcodes::Opcode> for bitcoin::blockdata::script::witness_version::WitnessVersion
@ -7050,7 +7048,6 @@ pub fn alloc::vec::Vec<u8>::consensus_decode_from_finite_reader<R: bitcoin_io::B
pub fn alloc::vec::Vec<u8>::consensus_encode<W: bitcoin_io::Write + core::marker::Sized>(&self, w: &mut W) -> core::result::Result<usize, bitcoin_io::error::Error> pub fn alloc::vec::Vec<u8>::consensus_encode<W: bitcoin_io::Write + core::marker::Sized>(&self, w: &mut W) -> core::result::Result<usize, bitcoin_io::error::Error>
pub fn alloc::vec::Vec<u8>::from(v: bitcoin::blockdata::script::ScriptBuf) -> Self pub fn alloc::vec::Vec<u8>::from(v: bitcoin::blockdata::script::ScriptBuf) -> Self
pub fn alloc::vec::Vec<u8>::from(value: bitcoin::blockdata::script::PushBytesBuf) -> Self pub fn alloc::vec::Vec<u8>::from(value: bitcoin::blockdata::script::PushBytesBuf) -> Self
pub fn bech32::primitives::gf32::Fe32::from(version: bitcoin::blockdata::script::witness_version::WitnessVersion) -> Self
pub fn bitcoin::CompressedPublicKey::clone(&self) -> bitcoin::CompressedPublicKey pub fn bitcoin::CompressedPublicKey::clone(&self) -> bitcoin::CompressedPublicKey
pub fn bitcoin::CompressedPublicKey::cmp(&self, other: &bitcoin::CompressedPublicKey) -> core::cmp::Ordering pub fn bitcoin::CompressedPublicKey::cmp(&self, other: &bitcoin::CompressedPublicKey) -> core::cmp::Ordering
pub fn bitcoin::CompressedPublicKey::deserialize<D: serde::de::Deserializer<'de>>(d: D) -> core::result::Result<Self, <D as serde::de::Deserializer>::Error> pub fn bitcoin::CompressedPublicKey::deserialize<D: serde::de::Deserializer<'de>>(d: D) -> core::result::Result<Self, <D as serde::de::Deserializer>::Error>
@ -8389,12 +8386,10 @@ pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::fmt(&self, f
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::from_str(s: &str) -> core::result::Result<Self, Self::Err> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::from_str(s: &str) -> core::result::Result<Self, Self::Err>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::hash<__H: core::hash::Hasher>(&self, state: &mut __H)
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::partial_cmp(&self, other: &bitcoin::blockdata::script::witness_version::WitnessVersion) -> core::option::Option<core::cmp::Ordering> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::partial_cmp(&self, other: &bitcoin::blockdata::script::witness_version::WitnessVersion) -> core::option::Option<core::cmp::Ordering>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_fe(self) -> bech32::primitives::gf32::Fe32
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_num(self) -> u8 pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_num(self) -> u8
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(instruction: bitcoin::blockdata::script::Instruction<'_>) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(instruction: bitcoin::blockdata::script::Instruction<'_>) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(no: u8) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(no: u8) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(opcode: bitcoin::blockdata::opcodes::Opcode) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(opcode: bitcoin::blockdata::opcodes::Opcode) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(value: bech32::primitives::gf32::Fe32) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::write_scriptint(out: &mut [u8; 8], n: i64) -> usize pub fn bitcoin::blockdata::script::write_scriptint(out: &mut [u8; 8], n: i64) -> usize
pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::clone(&self) -> bitcoin::blockdata::transaction::IndexOutOfBoundsError pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::clone(&self) -> bitcoin::blockdata::transaction::IndexOutOfBoundsError
pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::eq(&self, other: &bitcoin::blockdata::transaction::IndexOutOfBoundsError) -> bool pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::eq(&self, other: &bitcoin::blockdata::transaction::IndexOutOfBoundsError) -> bool

View File

@ -1814,7 +1814,6 @@ impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromErr
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::address::error::ParseError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::address::error::ParseError
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::FromStrError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::FromStrError
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::TryFromInstructionError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::TryFromInstructionError
impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bech32::primitives::gf32::Fe32
impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bitcoin::blockdata::opcodes::Opcode impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bitcoin::blockdata::opcodes::Opcode
impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::InputsIndexError impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::InputsIndexError
impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::OutputsIndexError impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::OutputsIndexError
@ -1966,7 +1965,6 @@ impl core::convert::TryFrom<alloc::string::String> for bitcoin::blockdata::trans
impl core::convert::TryFrom<alloc::string::String> for bitcoin::p2p::message::CommandString impl core::convert::TryFrom<alloc::string::String> for bitcoin::p2p::message::CommandString
impl core::convert::TryFrom<alloc::vec::Vec<bitcoin::taproot::TapNodeHash>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch impl core::convert::TryFrom<alloc::vec::Vec<bitcoin::taproot::TapNodeHash>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch
impl core::convert::TryFrom<alloc::vec::Vec<u8>> for bitcoin::blockdata::script::PushBytesBuf impl core::convert::TryFrom<alloc::vec::Vec<u8>> for bitcoin::blockdata::script::PushBytesBuf
impl core::convert::TryFrom<bech32::primitives::gf32::Fe32> for bitcoin::blockdata::script::witness_version::WitnessVersion
impl core::convert::TryFrom<bitcoin::PublicKey> for bitcoin::CompressedPublicKey impl core::convert::TryFrom<bitcoin::PublicKey> for bitcoin::CompressedPublicKey
impl core::convert::TryFrom<bitcoin::blockdata::constants::ChainHash> for bitcoin::network::Network impl core::convert::TryFrom<bitcoin::blockdata::constants::ChainHash> for bitcoin::network::Network
impl core::convert::TryFrom<bitcoin::blockdata::opcodes::Opcode> for bitcoin::blockdata::script::witness_version::WitnessVersion impl core::convert::TryFrom<bitcoin::blockdata::opcodes::Opcode> for bitcoin::blockdata::script::witness_version::WitnessVersion
@ -6744,7 +6742,6 @@ pub fn alloc::vec::Vec<u8>::consensus_decode_from_finite_reader<R: bitcoin_io::B
pub fn alloc::vec::Vec<u8>::consensus_encode<W: bitcoin_io::Write + core::marker::Sized>(&self, w: &mut W) -> core::result::Result<usize, bitcoin_io::error::Error> pub fn alloc::vec::Vec<u8>::consensus_encode<W: bitcoin_io::Write + core::marker::Sized>(&self, w: &mut W) -> core::result::Result<usize, bitcoin_io::error::Error>
pub fn alloc::vec::Vec<u8>::from(v: bitcoin::blockdata::script::ScriptBuf) -> Self pub fn alloc::vec::Vec<u8>::from(v: bitcoin::blockdata::script::ScriptBuf) -> Self
pub fn alloc::vec::Vec<u8>::from(value: bitcoin::blockdata::script::PushBytesBuf) -> Self pub fn alloc::vec::Vec<u8>::from(value: bitcoin::blockdata::script::PushBytesBuf) -> Self
pub fn bech32::primitives::gf32::Fe32::from(version: bitcoin::blockdata::script::witness_version::WitnessVersion) -> Self
pub fn bitcoin::CompressedPublicKey::clone(&self) -> bitcoin::CompressedPublicKey pub fn bitcoin::CompressedPublicKey::clone(&self) -> bitcoin::CompressedPublicKey
pub fn bitcoin::CompressedPublicKey::cmp(&self, other: &bitcoin::CompressedPublicKey) -> core::cmp::Ordering pub fn bitcoin::CompressedPublicKey::cmp(&self, other: &bitcoin::CompressedPublicKey) -> core::cmp::Ordering
pub fn bitcoin::CompressedPublicKey::eq(&self, other: &bitcoin::CompressedPublicKey) -> bool pub fn bitcoin::CompressedPublicKey::eq(&self, other: &bitcoin::CompressedPublicKey) -> bool
@ -8000,12 +7997,10 @@ pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::fmt(&self, f
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::from_str(s: &str) -> core::result::Result<Self, Self::Err> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::from_str(s: &str) -> core::result::Result<Self, Self::Err>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::hash<__H: core::hash::Hasher>(&self, state: &mut __H)
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::partial_cmp(&self, other: &bitcoin::blockdata::script::witness_version::WitnessVersion) -> core::option::Option<core::cmp::Ordering> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::partial_cmp(&self, other: &bitcoin::blockdata::script::witness_version::WitnessVersion) -> core::option::Option<core::cmp::Ordering>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_fe(self) -> bech32::primitives::gf32::Fe32
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_num(self) -> u8 pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_num(self) -> u8
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(instruction: bitcoin::blockdata::script::Instruction<'_>) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(instruction: bitcoin::blockdata::script::Instruction<'_>) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(no: u8) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(no: u8) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(opcode: bitcoin::blockdata::opcodes::Opcode) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(opcode: bitcoin::blockdata::opcodes::Opcode) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(value: bech32::primitives::gf32::Fe32) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::write_scriptint(out: &mut [u8; 8], n: i64) -> usize pub fn bitcoin::blockdata::script::write_scriptint(out: &mut [u8; 8], n: i64) -> usize
pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::clone(&self) -> bitcoin::blockdata::transaction::IndexOutOfBoundsError pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::clone(&self) -> bitcoin::blockdata::transaction::IndexOutOfBoundsError
pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::eq(&self, other: &bitcoin::blockdata::transaction::IndexOutOfBoundsError) -> bool pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::eq(&self, other: &bitcoin::blockdata::transaction::IndexOutOfBoundsError) -> bool

View File

@ -1650,7 +1650,6 @@ impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromErr
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::address::error::ParseError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::address::error::ParseError
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::FromStrError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::FromStrError
impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::TryFromInstructionError impl core::convert::From<bitcoin::blockdata::script::witness_version::TryFromError> for bitcoin::blockdata::script::witness_version::TryFromInstructionError
impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bech32::primitives::gf32::Fe32
impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bitcoin::blockdata::opcodes::Opcode impl core::convert::From<bitcoin::blockdata::script::witness_version::WitnessVersion> for bitcoin::blockdata::opcodes::Opcode
impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::InputsIndexError impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::InputsIndexError
impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::OutputsIndexError impl core::convert::From<bitcoin::blockdata::transaction::IndexOutOfBoundsError> for bitcoin::blockdata::transaction::OutputsIndexError
@ -1792,7 +1791,6 @@ impl core::convert::TryFrom<&bitcoin::blockdata::script::ScriptBuf> for bitcoin:
impl core::convert::TryFrom<alloc::boxed::Box<[bitcoin::taproot::TapNodeHash]>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch impl core::convert::TryFrom<alloc::boxed::Box<[bitcoin::taproot::TapNodeHash]>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch
impl core::convert::TryFrom<alloc::vec::Vec<bitcoin::taproot::TapNodeHash>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch impl core::convert::TryFrom<alloc::vec::Vec<bitcoin::taproot::TapNodeHash>> for bitcoin::taproot::merkle_branch::TaprootMerkleBranch
impl core::convert::TryFrom<alloc::vec::Vec<u8>> for bitcoin::blockdata::script::PushBytesBuf impl core::convert::TryFrom<alloc::vec::Vec<u8>> for bitcoin::blockdata::script::PushBytesBuf
impl core::convert::TryFrom<bech32::primitives::gf32::Fe32> for bitcoin::blockdata::script::witness_version::WitnessVersion
impl core::convert::TryFrom<bitcoin::PublicKey> for bitcoin::CompressedPublicKey impl core::convert::TryFrom<bitcoin::PublicKey> for bitcoin::CompressedPublicKey
impl core::convert::TryFrom<bitcoin::blockdata::constants::ChainHash> for bitcoin::network::Network impl core::convert::TryFrom<bitcoin::blockdata::constants::ChainHash> for bitcoin::network::Network
impl core::convert::TryFrom<bitcoin::blockdata::opcodes::Opcode> for bitcoin::blockdata::script::witness_version::WitnessVersion impl core::convert::TryFrom<bitcoin::blockdata::opcodes::Opcode> for bitcoin::blockdata::script::witness_version::WitnessVersion
@ -6110,7 +6108,6 @@ pub fn alloc::vec::Vec<u8>::consensus_decode_from_finite_reader<R: bitcoin_io::B
pub fn alloc::vec::Vec<u8>::consensus_encode<W: bitcoin_io::Write + core::marker::Sized>(&self, w: &mut W) -> core::result::Result<usize, bitcoin_io::error::Error> pub fn alloc::vec::Vec<u8>::consensus_encode<W: bitcoin_io::Write + core::marker::Sized>(&self, w: &mut W) -> core::result::Result<usize, bitcoin_io::error::Error>
pub fn alloc::vec::Vec<u8>::from(v: bitcoin::blockdata::script::ScriptBuf) -> Self pub fn alloc::vec::Vec<u8>::from(v: bitcoin::blockdata::script::ScriptBuf) -> Self
pub fn alloc::vec::Vec<u8>::from(value: bitcoin::blockdata::script::PushBytesBuf) -> Self pub fn alloc::vec::Vec<u8>::from(value: bitcoin::blockdata::script::PushBytesBuf) -> Self
pub fn bech32::primitives::gf32::Fe32::from(version: bitcoin::blockdata::script::witness_version::WitnessVersion) -> Self
pub fn bitcoin::CompressedPublicKey::clone(&self) -> bitcoin::CompressedPublicKey pub fn bitcoin::CompressedPublicKey::clone(&self) -> bitcoin::CompressedPublicKey
pub fn bitcoin::CompressedPublicKey::cmp(&self, other: &bitcoin::CompressedPublicKey) -> core::cmp::Ordering pub fn bitcoin::CompressedPublicKey::cmp(&self, other: &bitcoin::CompressedPublicKey) -> core::cmp::Ordering
pub fn bitcoin::CompressedPublicKey::eq(&self, other: &bitcoin::CompressedPublicKey) -> bool pub fn bitcoin::CompressedPublicKey::eq(&self, other: &bitcoin::CompressedPublicKey) -> bool
@ -7348,12 +7345,10 @@ pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::fmt(&self, f
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::from_str(s: &str) -> core::result::Result<Self, Self::Err> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::from_str(s: &str) -> core::result::Result<Self, Self::Err>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::hash<__H: core::hash::Hasher>(&self, state: &mut __H) pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::hash<__H: core::hash::Hasher>(&self, state: &mut __H)
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::partial_cmp(&self, other: &bitcoin::blockdata::script::witness_version::WitnessVersion) -> core::option::Option<core::cmp::Ordering> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::partial_cmp(&self, other: &bitcoin::blockdata::script::witness_version::WitnessVersion) -> core::option::Option<core::cmp::Ordering>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_fe(self) -> bech32::primitives::gf32::Fe32
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_num(self) -> u8 pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::to_num(self) -> u8
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(instruction: bitcoin::blockdata::script::Instruction<'_>) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(instruction: bitcoin::blockdata::script::Instruction<'_>) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(no: u8) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(no: u8) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(opcode: bitcoin::blockdata::opcodes::Opcode) -> core::result::Result<Self, Self::Error> pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(opcode: bitcoin::blockdata::opcodes::Opcode) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::witness_version::WitnessVersion::try_from(value: bech32::primitives::gf32::Fe32) -> core::result::Result<Self, Self::Error>
pub fn bitcoin::blockdata::script::write_scriptint(out: &mut [u8; 8], n: i64) -> usize pub fn bitcoin::blockdata::script::write_scriptint(out: &mut [u8; 8], n: i64) -> usize
pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::clone(&self) -> bitcoin::blockdata::transaction::IndexOutOfBoundsError pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::clone(&self) -> bitcoin::blockdata::transaction::IndexOutOfBoundsError
pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::eq(&self, other: &bitcoin::blockdata::transaction::IndexOutOfBoundsError) -> bool pub fn bitcoin::blockdata::transaction::IndexOutOfBoundsError::eq(&self, other: &bitcoin::blockdata::transaction::IndexOutOfBoundsError) -> bool

View File

@ -33,6 +33,7 @@ use core::marker::PhantomData;
use core::str::FromStr; use core::str::FromStr;
use bech32::primitives::hrp::Hrp; use bech32::primitives::hrp::Hrp;
use bech32::primitives::gf32::Fe32;
use hashes::{sha256, HashEngine}; use hashes::{sha256, HashEngine};
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey}; use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
@ -168,7 +169,8 @@ impl fmt::Display for AddressInner {
} }
Segwit { program, hrp } => { Segwit { program, hrp } => {
let hrp = hrp.to_hrp(); let hrp = hrp.to_hrp();
let version = program.version().to_fe(); let version = Fe32::try_from(program.version().to_num())
.expect("version nums 0-16 are valid fe32 values");
let program = program.program().as_ref(); let program = program.program().as_ref();
if fmt.alternate() { if fmt.alternate() {
@ -829,7 +831,7 @@ impl FromStr for Address<NetworkUnchecked> {
fn from_str(s: &str) -> Result<Address<NetworkUnchecked>, ParseError> { fn from_str(s: &str) -> Result<Address<NetworkUnchecked>, ParseError> {
if let Ok((hrp, witness_version, data)) = bech32::segwit::decode(s) { if let Ok((hrp, witness_version, data)) = bech32::segwit::decode(s) {
let version = WitnessVersion::try_from(witness_version)?; let version = WitnessVersion::try_from(witness_version.to_u8())?;
let program = WitnessProgram::new(version, &data) let program = WitnessProgram::new(version, &data)
.expect("bech32 guarantees valid program length for witness"); .expect("bech32 guarantees valid program length for witness");

View File

@ -10,7 +10,6 @@
use core::fmt; use core::fmt;
use core::str::FromStr; use core::str::FromStr;
use bech32::Fe32;
use internals::write_err; use internals::write_err;
use units::{parse, ParseIntError}; use units::{parse, ParseIntError};
@ -71,11 +70,6 @@ impl WitnessVersion {
/// version in bitcoin script. Thus, there is no function to directly convert witness version /// version in bitcoin script. Thus, there is no function to directly convert witness version
/// into a byte since the conversion requires context (bitcoin script or just a version number). /// into a byte since the conversion requires context (bitcoin script or just a version number).
pub fn to_num(self) -> u8 { self as u8 } pub fn to_num(self) -> u8 { self as u8 }
/// Converts this witness version to a GF32 field element.
pub fn to_fe(self) -> Fe32 {
Fe32::try_from(self.to_num()).expect("0-16 are valid fe32 values")
}
} }
/// Prints [`WitnessVersion`] number (from 0 to 16) as integer, without any prefix or suffix. /// Prints [`WitnessVersion`] number (from 0 to 16) as integer, without any prefix or suffix.
@ -92,12 +86,6 @@ impl FromStr for WitnessVersion {
} }
} }
impl TryFrom<bech32::Fe32> for WitnessVersion {
type Error = TryFromError;
fn try_from(value: Fe32) -> Result<Self, Self::Error> { Self::try_from(value.to_u8()) }
}
impl TryFrom<u8> for WitnessVersion { impl TryFrom<u8> for WitnessVersion {
type Error = TryFromError; type Error = TryFromError;
@ -152,10 +140,6 @@ impl<'a> TryFrom<Instruction<'a>> for WitnessVersion {
} }
} }
impl From<WitnessVersion> for Fe32 {
fn from(version: WitnessVersion) -> Self { version.to_fe() }
}
impl From<WitnessVersion> for Opcode { impl From<WitnessVersion> for Opcode {
fn from(version: WitnessVersion) -> Opcode { fn from(version: WitnessVersion) -> Opcode {
match version { match version {