Struct bitcoin::blockdata::script::Script [−][src]
pub struct Script(_);
A Bitcoin script
Implementations
impl Script
[src]
impl Script
[src]pub fn new() -> Script
[src]
Creates a new empty script
pub fn new_p2pk(pubkey: &PublicKey) -> Script
[src]
Generates P2PK-type of scriptPubkey
pub fn new_p2pkh(pubkey_hash: &PubkeyHash) -> Script
[src]
Generates P2PKH-type of scriptPubkey
pub fn new_p2sh(script_hash: &ScriptHash) -> Script
[src]
Generates P2SH-type of scriptPubkey with a given hash of the redeem script
pub fn new_v0_wpkh(pubkey_hash: &WPubkeyHash) -> Script
[src]
Generates P2WPKH-type of scriptPubkey
pub fn new_v0_wsh(script_hash: &WScriptHash) -> Script
[src]
Generates P2WSH-type of scriptPubkey with a given hash of the redeem script
pub fn new_witness_program(ver: u5, program: &[u8]) -> Script
[src]
Generates P2WSH-type of scriptPubkey with a given hash of the redeem script
pub fn new_op_return(data: &[u8]) -> Script
[src]
Generates OP_RETURN-type of scriptPubkey for a given data
pub fn script_hash(&self) -> ScriptHash
[src]
Returns 160-bit hash of the script
pub fn wscript_hash(&self) -> WScriptHash
[src]
Returns 256-bit hash of the script for P2WSH outputs
pub fn len(&self) -> usize
[src]
The length in bytes of the script
pub fn is_empty(&self) -> bool
[src]
Whether the script is the empty script
pub fn as_bytes(&self) -> &[u8]
[src]
Returns the script data
pub fn to_bytes(&self) -> Vec<u8>
[src]
Returns a copy of the script data
pub fn into_bytes(self) -> Vec<u8>
[src]
Convert the script into a byte vector
pub fn to_p2sh(&self) -> Script
[src]
Compute the P2SH output corresponding to this redeem script
pub fn to_v0_p2wsh(&self) -> Script
[src]
Compute the P2WSH output corresponding to this witnessScript (aka the “witness redeem script”)
pub fn is_p2sh(&self) -> bool
[src]
Checks whether a script pubkey is a p2sh output
pub fn is_p2pkh(&self) -> bool
[src]
Checks whether a script pubkey is a p2pkh output
pub fn is_p2pk(&self) -> bool
[src]
Checks whether a script pubkey is a p2pk output
pub fn is_witness_program(&self) -> bool
[src]
Checks whether a script pubkey is a Segregated Witness (segwit) program.
pub fn is_v0_p2wsh(&self) -> bool
[src]
Checks whether a script pubkey is a p2wsh output
pub fn is_v0_p2wpkh(&self) -> bool
[src]
Checks whether a script pubkey is a p2wpkh output
pub fn is_op_return(&self) -> bool
[src]
Check if this is an OP_RETURN output
pub fn is_provably_unspendable(&self) -> bool
[src]
Whether a script can be proven to have no satisfying input
pub fn dust_value(&self) -> u64
[src]
Gets the minimum value an output with this script should have in order to be broadcastable on today’s bitcoin network.
pub fn instructions(&self) -> Instructions<'_>ⓘNotable traits for Instructions<'a>
impl<'a> Iterator for Instructions<'a> type Item = Result<Instruction<'a>, Error>;
[src]
Notable traits for Instructions<'a>
impl<'a> Iterator for Instructions<'a> type Item = Result<Instruction<'a>, Error>;
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 Self::instructions_minimal.
pub fn instructions_minimal(&self) -> Instructions<'_>ⓘNotable traits for Instructions<'a>
impl<'a> Iterator for Instructions<'a> type Item = Result<Instruction<'a>, Error>;
[src]
Notable traits for Instructions<'a>
impl<'a> Iterator for Instructions<'a> type Item = Result<Instruction<'a>, Error>;
Iterate over the script in the form of Instruction
s while enforcing
minimal pushes.
pub fn bytes_to_asm_fmt(script: &[u8], f: &mut dyn Write) -> Result
[src]
Write the assembly decoding of the script bytes to the formatter.
pub fn fmt_asm(&self, f: &mut dyn Write) -> Result
[src]
Write the assembly decoding of the script to the formatter.
pub fn bytes_to_asm(script: &[u8]) -> String
[src]
Create an assembly decoding of the script in the given byte slice.
pub fn asm(&self) -> String
[src]
Get the assembly decoding of the script.
Trait Implementations
impl Deserialize for Script
[src]
impl Deserialize for Script
[src]impl<'de> Deserialize<'de> for Script
[src]
impl<'de> Deserialize<'de> for Script
[src]fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl FromHex for Script
[src]
impl FromHex for Script
[src]fn from_byte_iter<I>(iter: I) -> Result<Self, Error> where
I: Iterator<Item = Result<u8, Error>> + ExactSizeIterator + DoubleEndedIterator,
[src]
I: Iterator<Item = Result<u8, Error>> + ExactSizeIterator + DoubleEndedIterator,
pub fn from_hex(s: &str) -> Result<Self, Error>
[src]
impl PartialOrd<Script> for Script
[src]
impl PartialOrd<Script> for Script
[src]impl Eq for Script
[src]
impl StructuralEq for Script
[src]
impl StructuralPartialEq for Script
[src]
Auto Trait Implementations
impl RefUnwindSafe for Script
impl Send for Script
impl Sync for Script
impl Unpin for Script
impl UnwindSafe for Script
Blanket Implementations
impl<T> ToBase32 for T where
T: AsRef<[u8]>,
[src]
impl<T> ToBase32 for T where
T: AsRef<[u8]>,
[src]pub fn write_base32<W>(
&self,
writer: &mut W
) -> Result<(), <W as WriteBase32>::Err> where
W: WriteBase32,
[src]
&self,
writer: &mut W
) -> Result<(), <W as WriteBase32>::Err> where
W: WriteBase32,
pub fn to_base32(&self) -> Vec<u5, Global>
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,