pub struct Script(/* private fields */);
Expand description
A Bitcoin script
Implementations§
source§impl Script
impl Script
sourcepub fn into_bytes(self) -> Vec<u8>
pub fn into_bytes(self) -> Vec<u8>
Convert the script into a byte vector
sourcepub fn to_v0_p2wsh(&self) -> Script
pub fn to_v0_p2wsh(&self) -> Script
Compute the P2WSH output corresponding to this witnessScript (aka the “witness redeem script”)
sourcepub fn is_witness_program(&self) -> bool
pub fn is_witness_program(&self) -> bool
Checks whether a script pubkey is a Segregated Witness (segwit) program.
sourcepub fn is_v0_p2wsh(&self) -> bool
pub fn is_v0_p2wsh(&self) -> bool
Checks whether a script pubkey is a p2wsh output
sourcepub fn is_v0_p2wpkh(&self) -> bool
pub fn is_v0_p2wpkh(&self) -> bool
Checks whether a script pubkey is a p2wpkh output
sourcepub fn is_op_return(&self) -> bool
pub fn is_op_return(&self) -> bool
Check if this is an OP_RETURN output
sourcepub fn is_provably_unspendable(&self) -> bool
pub fn is_provably_unspendable(&self) -> bool
Whether a script can be proven to have no satisfying input
sourcepub fn is_colored(&self) -> bool
pub fn is_colored(&self) -> bool
Check if a script pubkey is a colored coin script
sourcepub fn is_multisig(&self) -> bool
pub fn is_multisig(&self) -> bool
Check if a script pubkey is multisig script
sourcepub fn get_multisig_pubkeys(
&self
) -> Result<(i32, Vec<PublicKey>), MultisigError>
pub fn get_multisig_pubkeys( &self ) -> Result<(i32, Vec<PublicKey>), MultisigError>
Return public keys for multisig script, and the number of signatures required
sourcepub fn add_color(
&self,
color_id: ColorIdentifier
) -> Result<Script, ColoredCoinError>
pub fn add_color( &self, color_id: ColorIdentifier ) -> Result<Script, ColoredCoinError>
Create new script with color identifier
sourcepub fn instructions(&self) -> Instructions<'_> ⓘ
pub fn instructions(&self) -> Instructions<'_> ⓘ
Iterate over the script in the form of Instruction
s, which are an 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, treat
it as a slice using script[..]
or convert it to a vector using into_bytes()
.
To force minimal pushes, use [instructions_minimal].
sourcepub fn instructions_minimal(&self) -> Instructions<'_> ⓘ
pub fn instructions_minimal(&self) -> Instructions<'_> ⓘ
Iterate over the script in the form of Instruction
s while enforcing
minimal pushes.
sourcepub fn fmt_asm(&self, f: &mut dyn Write) -> Result
pub fn fmt_asm(&self, f: &mut dyn Write) -> Result
Write the assembly decoding of the script to the formatter.
sourcepub fn split_color(&self) -> Option<(ColorIdentifier, Script)>
pub fn split_color(&self) -> Option<(ColorIdentifier, Script)>
Extract a color_id and a remaining script Return None if script is not colored coin
sourcepub fn script_type(&self) -> ScriptType
pub fn script_type(&self) -> ScriptType
Return script type.
Trait Implementations§
source§impl Deserialize for Script
impl Deserialize for Script
source§impl Ord for Script
impl Ord for Script
source§impl PartialEq for Script
impl PartialEq for Script
source§impl PartialOrd for Script
impl PartialOrd for Script
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more