pub struct BURN_SCRIPT { /* private fields */ }
Methods from Deref<Target = ScriptBuf>§
pub fn as_script(&self) -> &Script
pub fn as_script(&self) -> &Script
Returns a reference to unsized script.
Methods from Deref<Target = Script>§
pub fn as_mut_bytes(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_bytes(&mut self) -> &mut [u8] ⓘ
Returns the script data as a mutable byte slice.
pub fn script_hash(&self) -> ScriptHash
pub fn script_hash(&self) -> ScriptHash
Returns 160-bit hash of the script.
pub fn wscript_hash(&self) -> WScriptHash
pub fn wscript_hash(&self) -> WScriptHash
Returns 256-bit hash of the script for P2WSH outputs.
pub fn tapscript_leaf_hash(&self) -> TapLeafHash
pub fn tapscript_leaf_hash(&self) -> TapLeafHash
Computes leaf hash of tapscript.
pub fn bytes(&self) -> Bytes<'_>
pub fn bytes(&self) -> Bytes<'_>
Returns an iterator over script bytes.
pub fn to_p2wsh(&self) -> ScriptBuf
pub fn to_p2wsh(&self) -> ScriptBuf
Computes the P2WSH output corresponding to this witnessScript (aka the “witness redeem script”).
pub fn to_p2tr<C>(
&self,
secp: &Secp256k1<C>,
internal_key: XOnlyPublicKey,
) -> ScriptBufwhere
C: Verification,
pub fn to_p2tr<C>(
&self,
secp: &Secp256k1<C>,
internal_key: XOnlyPublicKey,
) -> ScriptBufwhere
C: Verification,
Computes P2TR output with a given internal key and a single script spending path equal to the current script, assuming that the script is a Tapscript.
pub fn witness_version(&self) -> Option<WitnessVersion>
pub fn witness_version(&self) -> Option<WitnessVersion>
Returns witness version of the script, if any, assuming the script is a scriptPubkey
.
§Returns
The witness version if this script is found to conform to the SegWit rules:
A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of a 1-byte push opcode (for 0 to 16) followed by a data push between 2 and 40 bytes gets a new special meaning. The value of the first push is called the “version byte”. The following byte vector pushed is called the “witness program”.
pub fn is_push_only(&self) -> bool
pub fn is_push_only(&self) -> bool
Checks whether a script is push only.
Note: OP_RESERVED
(0x50
) and all the OP_PUSHNUM operations
are considered push operations.
pub fn is_p2pk(&self) -> bool
pub fn is_p2pk(&self) -> bool
Checks whether a script pubkey is a P2PK output.
You can obtain the public key, if its valid,
by calling p2pk_public_key()
pub fn p2pk_public_key(&self) -> Option<PublicKey>
pub fn p2pk_public_key(&self) -> Option<PublicKey>
Returns the public key if this script is P2PK with a valid public key.
This may return None
even when is_p2pk()
returns true.
This happens when the public key is invalid (e.g. the point not being on the curve).
In this situation the script is unspendable.
pub fn is_multisig(&self) -> bool
pub fn is_multisig(&self) -> bool
Checks whether a script pubkey is a bare multisig output.
In a bare multisig pubkey script the keys are not hashed, the script is of the form:
2 <pubkey1> <pubkey2> <pubkey3> 3 OP_CHECKMULTISIG
pub fn is_witness_program(&self) -> bool
pub fn is_witness_program(&self) -> bool
Checks whether a script pubkey is a Segregated Witness (segwit) program.
pub fn is_op_return(&self) -> bool
pub fn is_op_return(&self) -> bool
Check if this is an OP_RETURN output.
pub fn is_provably_unspendable(&self) -> bool
👎Deprecated since 0.32.0: The method has potentially confusing semantics and is going to be removed, you might want is_op_return
pub fn is_provably_unspendable(&self) -> bool
is_op_return
Checks whether a script is trivially known to have no satisfying input.
This method has potentially confusing semantics and an unclear purpose, so it’s going to be
removed. Use is_op_return
if you want OP_RETURN
semantics.
pub fn to_p2sh(&self) -> ScriptBuf
pub fn to_p2sh(&self) -> ScriptBuf
Computes the P2SH output corresponding to this redeem script.
pub fn p2wpkh_script_code(&self) -> Option<ScriptBuf>
pub fn p2wpkh_script_code(&self) -> Option<ScriptBuf>
Returns the script code used for spending a P2WPKH output if this script is a script pubkey
for a P2WPKH output. The scriptCode
is described in BIP143.
pub fn redeem_script(&self) -> Option<&Script>
pub fn redeem_script(&self) -> Option<&Script>
Get redeemScript following BIP16 rules regarding P2SH spending.
This does not guarantee that this represents a P2SH input [Script
].
It merely gets the last push of the script. Use
Script::is_p2sh
on the
scriptPubKey to check whether it is actually a P2SH script.
pub fn dust_value(&self) -> Amount
👎Deprecated since 0.32.0: use minimal_non_dust and friends
pub fn dust_value(&self) -> Amount
Returns the minimum value an output with this script should have in order to be broadcastable on today’s Bitcoin network.
pub fn minimal_non_dust(&self) -> Amount
pub fn minimal_non_dust(&self) -> Amount
Returns the minimum value an output with this script should have in order to be broadcastable on today’s Bitcoin network.
Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to. This function uses the default value of 0.00003 BTC/kB (3 sat/vByte).
To use a custom value, use minimal_non_dust_custom
.
pub fn minimal_non_dust_custom(&self, dust_relay_fee: FeeRate) -> Amount
pub fn minimal_non_dust_custom(&self, dust_relay_fee: FeeRate) -> Amount
Returns the minimum value an output with this script should have in order to be broadcastable on today’s Bitcoin network.
Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to. This function lets you set the fee rate used in dust calculation.
The current default value in Bitcoin Core (as of v26) is 3 sat/vByte.
To use the default Bitcoin Core value, use minimal_non_dust
.
pub fn count_sigops(&self) -> usize
pub fn count_sigops(&self) -> usize
Counts the sigops for this Script using accurate counting.
In Bitcoin Core, there are two ways to count sigops, “accurate” and “legacy”. This method uses “accurate” counting. This means that OP_CHECKMULTISIG and its verify variant count for N sigops where N is the number of pubkeys used in the multisig. However, it will count for 20 sigops if CHECKMULTISIG is not preceded by an OP_PUSHNUM from 1 - 16 (this would be an invalid script)
Bitcoin Core uses accurate counting for sigops contained within redeemScripts (P2SH) and witnessScripts (P2WSH) only. It uses legacy for sigops in scriptSigs and scriptPubkeys.
(Note: taproot scripts don’t count toward the sigop count of the block, nor do they have CHECKMULTISIG operations. This function does not count OP_CHECKSIGADD, so do not use this to try and estimate if a taproot script goes over the sigop budget.)
pub fn count_sigops_legacy(&self) -> usize
pub fn count_sigops_legacy(&self) -> usize
Counts the sigops for this Script using legacy counting.
In Bitcoin Core, there are two ways to count sigops, “accurate” and “legacy”. This method uses “legacy” counting. This means that OP_CHECKMULTISIG and its verify variant count for 20 sigops.
Bitcoin Core uses legacy counting for sigops contained within scriptSigs and scriptPubkeys. It uses accurate for redeemScripts (P2SH) and witnessScripts (P2WSH).
(Note: taproot scripts don’t count toward the sigop count of the block, nor do they have CHECKMULTISIG operations. This function does not count OP_CHECKSIGADD, so do not use this to try and estimate if a taproot script goes over the sigop budget.)
pub fn instructions(&self) -> Instructions<'_>
pub fn instructions(&self) -> Instructions<'_>
Iterates over the script instructions.
Each returned item is a nested enum covering opcodes, datapushes and errors.
At most one error will be returned and then the iterator will end. To instead iterate over
the script as sequence of bytes call the bytes
method.
To force minimal pushes, use instructions_minimal
.
pub fn instructions_minimal(&self) -> Instructions<'_>
pub fn instructions_minimal(&self) -> Instructions<'_>
Iterates over the script instructions while enforcing minimal pushes.
This is similar to instructions
but an error is returned if a push
is not minimal.
pub fn instruction_indices(&self) -> InstructionIndices<'_>
pub fn instruction_indices(&self) -> InstructionIndices<'_>
Iterates over the script instructions and their indices.
Unless the script contains an error, the returned item consists of an index pointing to the position in the script where the instruction begins and the decoded instruction - either an opcode or data push.
To force minimal pushes, use [Self::instruction_indices_minimal
].
pub fn instruction_indices_minimal(&self) -> InstructionIndices<'_>
pub fn instruction_indices_minimal(&self) -> InstructionIndices<'_>
Iterates over the script instructions and their indices while enforcing minimal pushes.
This is similar to instruction_indices
but an error is
returned if a push is not minimal.
pub fn fmt_asm(&self, f: &mut dyn Write) -> Result<(), Error>
pub fn fmt_asm(&self, f: &mut dyn Write) -> Result<(), Error>
Writes the human-readable assembly representation of the script to the formatter.
pub fn to_asm_string(&self) -> String
pub fn to_asm_string(&self) -> String
Returns the human-readable assembly representation of the script.
pub fn to_hex_string(&self) -> String
pub fn to_hex_string(&self) -> String
Formats the script as lower-case hex.
This is a more convenient and performant way to write format!("{:x}", script)
.
For better performance you should generally prefer displaying the script but if String
is
required (this is common in tests) this method can be used.
pub fn first_opcode(&self) -> Option<Opcode>
pub fn first_opcode(&self) -> Option<Opcode>
Returns the first opcode of the script (if there is any).
pub fn verify(
&self,
index: usize,
amount: Amount,
spending_tx: &[u8],
) -> Result<(), BitcoinconsensusError>
pub fn verify( &self, index: usize, amount: Amount, spending_tx: &[u8], ) -> Result<(), BitcoinconsensusError>
Verifies spend of an input script.
Shorthand for [Self::verify_with_flags
] with flag bitcoinconsensus::VERIFY_ALL
.
§Parameters
index
- The input index in spending which is spending this transaction.amount
- The amount this script guards.spending_tx
- The transaction that attempts to spend the output holding this script.
pub fn verify_with_flags<F>(
&self,
index: usize,
amount: Amount,
spending_tx: &[u8],
flags: F,
) -> Result<(), BitcoinconsensusError>
pub fn verify_with_flags<F>( &self, index: usize, amount: Amount, spending_tx: &[u8], flags: F, ) -> Result<(), BitcoinconsensusError>
Verifies spend of an input script.
§Parameters
index
- The input index in spending which is spending this transaction.amount
- The amount this script guards.spending_tx
- The transaction that attempts to spend the output holding this script.flags
- Verification flags, seebitcoinconsensus::VERIFY_ALL
and similar.
Trait Implementations§
Source§impl Deref for BURN_SCRIPT
impl Deref for BURN_SCRIPT
impl LazyStatic for BURN_SCRIPT
Auto Trait Implementations§
impl Freeze for BURN_SCRIPT
impl RefUnwindSafe for BURN_SCRIPT
impl Send for BURN_SCRIPT
impl Sync for BURN_SCRIPT
impl Unpin for BURN_SCRIPT
impl UnwindSafe for BURN_SCRIPT
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.