pub struct Script { /* private fields */ }Expand description
A Tapscript builder for constructing Bitcoin scripts.
Implementations§
Source§impl Script
impl Script
Sourcepub fn push_opcode(self, opcode: Opcode) -> Self
pub fn push_opcode(self, opcode: Opcode) -> Self
Push an opcode onto the script.
Sourcepub fn push_data(self, data: &[u8]) -> Self
pub fn push_data(self, data: &[u8]) -> Self
Push raw data onto the script with appropriate push opcode.
Automatically selects the correct push operation based on data length:
- 1-75 bytes:
OP_PUSHBYTESn - 76-255 bytes:
OP_PUSHDATA1 - 256-65535 bytes:
OP_PUSHDATA2
Sourcepub fn push_key(self, x_only_pubkey: &[u8; 32]) -> Self
pub fn push_key(self, x_only_pubkey: &[u8; 32]) -> Self
Push a 32-byte x-only public key (BIP-340 Schnorr key).
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consume and return the raw script bytes.
Sourcepub fn script_hash(&self) -> [u8; 32]
pub fn script_hash(&self) -> [u8; 32]
Compute the script hash (SHA256).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Script
impl RefUnwindSafe for Script
impl Send for Script
impl Sync for Script
impl Unpin for Script
impl UnsafeUnpin for Script
impl UnwindSafe for 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
Mutably borrows from an owned value. Read more