pub struct LockingScript(/* private fields */);Expand description
Represents a locking script (output script / scriptPubKey).
A locking script defines the conditions that must be satisfied to spend the output it locks.
Implementations§
Source§impl LockingScript
impl LockingScript
Sourcepub fn from_chunks(chunks: Vec<ScriptChunk>) -> Self
pub fn from_chunks(chunks: Vec<ScriptChunk>) -> Self
Creates a locking script from a vector of chunks.
Sourcepub fn from_asm(asm: &str) -> Result<Self>
pub fn from_asm(asm: &str) -> Result<Self>
Constructs a LockingScript from an ASM formatted string.
Sourcepub fn from_hex(hex: &str) -> Result<Self>
pub fn from_hex(hex: &str) -> Result<Self>
Constructs a LockingScript from a hexadecimal string.
Sourcepub fn from_binary(bin: &[u8]) -> Result<Self>
pub fn from_binary(bin: &[u8]) -> Result<Self>
Constructs a LockingScript from binary data.
Sourcepub fn from_script(script: Script) -> Self
pub fn from_script(script: Script) -> Self
Constructs a LockingScript from a Script.
Sourcepub fn into_script(self) -> Script
pub fn into_script(self) -> Script
Converts this LockingScript into its underlying Script.
Sourcepub fn chunks(&self) -> Vec<ScriptChunk>
pub fn chunks(&self) -> Vec<ScriptChunk>
Returns the chunks.
Sourcepub fn is_push_only(&self) -> bool
pub fn is_push_only(&self) -> bool
Checks if push-only.
Sourcepub fn is_locking_script(&self) -> bool
pub fn is_locking_script(&self) -> bool
Returns true (this is a locking script).
Sourcepub fn is_unlocking_script(&self) -> bool
pub fn is_unlocking_script(&self) -> bool
Returns false (this is not an unlocking script).
Sourcepub fn to_address(&self) -> Option<Address>
pub fn to_address(&self) -> Option<Address>
Extracts a P2PKH address from this locking script, if it matches the
P2PKH pattern: OP_DUP OP_HASH160 <20 bytes> OP_EQUALVERIFY OP_CHECKSIG.
Returns None for non-P2PKH scripts.
§Example
use bsv_rs::script::LockingScript;
let script = LockingScript::from_hex("76a914...88ac")?;
if let Some(address) = script.to_address() {
println!("Address: {}", address);
}Trait Implementations§
Source§impl Clone for LockingScript
impl Clone for LockingScript
Source§fn clone(&self) -> LockingScript
fn clone(&self) -> LockingScript
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more