[−][src]Struct bitcoin::blockdata::script::Script
A Bitcoin script
Methods
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
ⓘImportant traits for Instructions<'a>pub fn instructions(&self) -> Instructions
[src]
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].
ⓘImportant traits for Instructions<'a>pub fn instructions_minimal(&self) -> Instructions
[src]
Iterate over the script in the form of Instruction
s while enforcing
minimal pushes.
pub fn fmt_asm(&self, f: &mut dyn Write) -> Result
[src]
Write the assembly decoding of the script to the formatter.
pub fn asm(&self) -> String
[src]
Get the assembly decoding of the script.
Trait Implementations
impl Serialize for Script
[src]
impl Deserialize for Script
[src]
impl Encodable for Script
[src]
impl Decodable for Script
[src]
fn consensus_decode<D: Read>(d: D) -> Result<Self, Error>
[src]
impl From<Vec<u8>> for Script
[src]
Creates a new script from an existing vector
impl Ord for Script
[src]
fn cmp(&self, other: &Script) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl PartialOrd<Script> for Script
[src]
fn partial_cmp(&self, other: &Script) -> Option<Ordering>
[src]
fn lt(&self, other: &Script) -> bool
[src]
fn le(&self, other: &Script) -> bool
[src]
fn gt(&self, other: &Script) -> bool
[src]
fn ge(&self, other: &Script) -> bool
[src]
impl Default for Script
[src]
impl Clone for Script
[src]
fn clone(&self) -> Script
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<Script> for Script
[src]
impl Eq for Script
[src]
impl Display for Script
[src]
impl Debug for Script
[src]
impl Index<usize> for Script
[src]
impl Index<Range<usize>> for Script
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: Range<usize>) -> &[u8]
[src]
impl Index<RangeTo<usize>> for Script
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeTo<usize>) -> &[u8]
[src]
impl Index<RangeFrom<usize>> for Script
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, index: RangeFrom<usize>) -> &[u8]
[src]
impl Index<RangeFull> for Script
[src]
impl Hash for Script
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromStr for Script
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Error>
[src]
impl LowerHex for Script
[src]
impl UpperHex 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,
fn from_hex(s: &str) -> Result<Self, Error>
[src]
Produce an object from a hex string
Auto Trait Implementations
impl Unpin for Script
impl Sync for Script
impl Send for Script
impl UnwindSafe for Script
impl RefUnwindSafe for Script
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToHex for T where
T: LowerHex,
[src]
T: LowerHex,
impl<T> FromHex for T where
T: Hash,
[src]
T: Hash,
fn from_byte_iter<I>(iter: I) -> Result<T, Error> where
I: Iterator<Item = Result<u8, Error>> + ExactSizeIterator + DoubleEndedIterator,
[src]
I: Iterator<Item = Result<u8, Error>> + ExactSizeIterator + DoubleEndedIterator,
fn from_hex(s: &str) -> Result<Self, Error>
[src]
Produce an object from a hex string