Skip to main content

ScriptType

Enum ScriptType 

Source
pub enum ScriptType<'a> {
    P2PKH {
        pubkey_hash: &'a [u8; 20],
    },
    P2SH {
        script_hash: &'a [u8; 20],
    },
    P2WPKH {
        pubkey_hash: &'a [u8; 20],
    },
    P2WSH {
        script_hash: &'a [u8; 32],
    },
    P2TR {
        x_only_pubkey: &'a [u8; 32],
    },
    P2PK {
        pubkey: &'a [u8],
    },
    OpReturn {
        data: &'a [u8],
    },
    Multisig {
        required: u8,
        total: u8,
    },
    Unknown,
}
Expand description

Known standard output script types.

Variants§

§

P2PKH

Pay-to-Public-Key-Hash: OP_DUP OP_HASH160 <20-byte hash> OP_EQUALVERIFY OP_CHECKSIG

Fields

§pubkey_hash: &'a [u8; 20]

RIPEMD-160(SHA-256(pubkey)) hash embedded in the script.

§

P2SH

Pay-to-Script-Hash: OP_HASH160 <20-byte hash> OP_EQUAL

Fields

§script_hash: &'a [u8; 20]

RIPEMD-160(SHA-256(redeem_script)) hash embedded in the script.

§

P2WPKH

Pay-to-Witness-Public-Key-Hash: OP_0 <20-byte hash>

Fields

§pubkey_hash: &'a [u8; 20]

Witness program: RIPEMD-160(SHA-256(pubkey)).

§

P2WSH

Pay-to-Witness-Script-Hash: OP_0 <32-byte hash>

Fields

§script_hash: &'a [u8; 32]

Witness program: SHA-256(witness_script).

§

P2TR

Pay-to-Taproot: OP_1 <32-byte x-only pubkey>

Fields

§x_only_pubkey: &'a [u8; 32]

Taproot output key (x-only, 32 bytes).

§

P2PK

Pay-to-Public-Key: <compressed/uncompressed pubkey> OP_CHECKSIG

Fields

§pubkey: &'a [u8]

Raw public key bytes (33 bytes compressed or 65 bytes uncompressed).

§

OpReturn

OP_RETURN / provably unspendable

Fields

§data: &'a [u8]

Arbitrary data payload following the OP_RETURN opcode.

§

Multisig

Multisig: OP_m <pubkeys…> OP_n OP_CHECKMULTISIG

Fields

§required: u8

Minimum number of signatures required to spend.

§total: u8

Total number of public keys listed.

§

Unknown

Anything else (non-standard / complex).

Trait Implementations§

Source§

impl<'a> Clone for ScriptType<'a>

Source§

fn clone(&self) -> ScriptType<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ScriptType<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for ScriptType<'a>

Source§

fn eq(&self, other: &ScriptType<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Copy for ScriptType<'a>

Source§

impl<'a> Eq for ScriptType<'a>

Source§

impl<'a> StructuralPartialEq for ScriptType<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ScriptType<'a>

§

impl<'a> RefUnwindSafe for ScriptType<'a>

§

impl<'a> Send for ScriptType<'a>

§

impl<'a> Sync for ScriptType<'a>

§

impl<'a> Unpin for ScriptType<'a>

§

impl<'a> UnsafeUnpin for ScriptType<'a>

§

impl<'a> UnwindSafe for ScriptType<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.