#[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

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.

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.

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.

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.

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).

Determines the checksum variant. See BIP-0350 for specification.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Prints WitnessVersion number (from 0 to 16) as integer, without any prefix or suffix.

Formats the value using the given formatter. Read more

Converts WitnessVersion instance into corresponding Bitcoin scriptopcode (OP_0..OP_16).

Converts WitnessVersion instance into corresponding Bech32(m) u5-value (bech32::u5).

The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.