Enum bitcoin::util::address::WitnessVersion
source · #[repr(u8)]
pub enum WitnessVersion {
Show 17 variants
V0,
V1,
V2,
V3,
V4,
V5,
V6,
V7,
V8,
V9,
V10,
V11,
V12,
V13,
V14,
V15,
V16,
}
Expand description
Version of the witness program.
Helps limit possible versions of the witness according to the specification. If a plain u8
type was used instead it would mean that the version may be > 16, which would be incorrect.
First byte of scriptPubkey
in transaction output for transactions starting with opcodes
ranging from 0 to 16 (inclusive).
Variants
V0
Initial version of witness program. Used for P2WPKH and P2WPK outputs
V1
Version of witness program used for Taproot P2TR outputs.
V2
Future (unsupported) version of witness program.
V3
Future (unsupported) version of witness program.
V4
Future (unsupported) version of witness program.
V5
Future (unsupported) version of witness program.
V6
Future (unsupported) version of witness program.
V7
Future (unsupported) version of witness program.
V8
Future (unsupported) version of witness program.
V9
Future (unsupported) version of witness program.
V10
Future (unsupported) version of witness program.
V11
Future (unsupported) version of witness program.
V12
Future (unsupported) version of witness program.
V13
Future (unsupported) version of witness program.
V14
Future (unsupported) version of witness program.
V15
Future (unsupported) version of witness program.
V16
Future (unsupported) version of witness program.
Implementations
sourceimpl WitnessVersion
impl WitnessVersion
sourcepub fn from_u5(value: u5) -> Result<Self, Error>
pub fn from_u5(value: u5) -> Result<Self, Error>
Converts 5-bit unsigned integer value matching single symbol from Bech32(m) address encoding
(bech32::u5
) into WitnessVersion
variant.
Returns
Version of the Witness program.
Errors
If the integer does not correspond to any witness version, errors with
Error::InvalidWitnessVersion
.
sourcepub fn from_num(no: u8) -> Result<Self, Error>
pub fn from_num(no: u8) -> Result<Self, Error>
Converts an 8-bit unsigned integer value into WitnessVersion
variant.
Returns
Version of the Witness program.
Errors
If the integer does not correspond to any witness version, errors with
Error::InvalidWitnessVersion
.
sourcepub fn from_opcode(opcode: All) -> Result<Self, Error>
pub fn from_opcode(opcode: All) -> Result<Self, Error>
Converts bitcoin script opcode into WitnessVersion
variant.
Returns
Version of the Witness program (for opcodes in range of OP_0
..OP_16
).
Errors
If the opcode does not correspond to any witness version, errors with
Error::MalformedWitnessVersion
.
sourcepub fn from_instruction(instruction: Instruction<'_>) -> Result<Self, Error>
pub fn from_instruction(instruction: Instruction<'_>) -> Result<Self, Error>
Converts bitcoin script Instruction
(parsed opcode) into WitnessVersion
variant.
Returns
Version of the Witness program for Instruction::Op
and Instruction::PushBytes
with
byte value within 1..=16
range.
Errors
If the opcode does not correspond to any witness version, errors with
Error::MalformedWitnessVersion
for the rest of opcodes.
sourcepub fn into_num(self) -> u8
pub fn into_num(self) -> u8
Returns integer version number representation for a given WitnessVersion
value.
NB: this is not the same as an integer representation of the opcode signifying witness 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).
sourcepub fn bech32_variant(&self) -> Variant
pub fn bech32_variant(&self) -> Variant
Determines the checksum variant. See BIP-0350 for specification.
Trait Implementations
sourceimpl Clone for WitnessVersion
impl Clone for WitnessVersion
sourcefn clone(&self) -> WitnessVersion
fn clone(&self) -> WitnessVersion
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for WitnessVersion
impl Debug for WitnessVersion
sourceimpl Display for WitnessVersion
impl Display for WitnessVersion
Prints WitnessVersion
number (from 0 to 16) as integer, without
any prefix or suffix.
sourceimpl From<WitnessVersion> for All
impl From<WitnessVersion> for All
sourcefn from(version: WitnessVersion) -> All
fn from(version: WitnessVersion) -> All
Converts WitnessVersion
instance into corresponding Bitcoin scriptopcode (OP_0
..OP_16
).
sourceimpl From<WitnessVersion> for u5
impl From<WitnessVersion> for u5
sourcefn from(version: WitnessVersion) -> Self
fn from(version: WitnessVersion) -> Self
Converts WitnessVersion
instance into corresponding Bech32(m) u5-value (bech32::u5
).
sourceimpl FromStr for WitnessVersion
impl FromStr for WitnessVersion
sourceimpl Hash for WitnessVersion
impl Hash for WitnessVersion
sourceimpl Ord for WitnessVersion
impl Ord for WitnessVersion
sourcefn cmp(&self, other: &WitnessVersion) -> Ordering
fn cmp(&self, other: &WitnessVersion) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl PartialEq<WitnessVersion> for WitnessVersion
impl PartialEq<WitnessVersion> for WitnessVersion
sourcefn eq(&self, other: &WitnessVersion) -> bool
fn eq(&self, other: &WitnessVersion) -> bool
sourceimpl PartialOrd<WitnessVersion> for WitnessVersion
impl PartialOrd<WitnessVersion> for WitnessVersion
sourcefn partial_cmp(&self, other: &WitnessVersion) -> Option<Ordering>
fn partial_cmp(&self, other: &WitnessVersion) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more