pub struct PushDrop {
pub fields: Vec<Vec<u8>>,
pub private_key: Option<PrivateKey>,
pub sighash_type: u32,
pub lock_position: LockPosition,
}Expand description
PushDrop script template for embedding data with spending control.
Creates a locking script that pushes data fields onto the stack, drops them with OP_DROP operations, then verifies a signature against a public key (OP_CHECKSIG).
Fields§
§fields: Vec<Vec<u8>>Data fields to embed in the script.
private_key: Option<PrivateKey>Private key for signing (used for both lock pubkey and unlock signature).
sighash_type: u32Sighash scope for signing (default: SIGHASH_ALL | SIGHASH_FORKID).
lock_position: LockPositionWhere the locking pubkey is placed in the script.
Implementations§
Source§impl PushDrop
impl PushDrop
Sourcepub fn new(fields: Vec<Vec<u8>>, key: PrivateKey) -> Self
pub fn new(fields: Vec<Vec<u8>>, key: PrivateKey) -> Self
Create a PushDrop template with data fields and a key for locking and unlocking.
Sourcepub fn lock_only(fields: Vec<Vec<u8>>) -> Self
pub fn lock_only(fields: Vec<Vec<u8>>) -> Self
Create a PushDrop template for locking only (no signing capability).
Sourcepub fn with_lock_position(self, position: LockPosition) -> Self
pub fn with_lock_position(self, position: LockPosition) -> Self
Set the lock position (builder pattern).
Sourcepub fn unlock(&self, preimage: &[u8]) -> Result<UnlockingScript, ScriptError>
pub fn unlock(&self, preimage: &[u8]) -> Result<UnlockingScript, ScriptError>
Create an unlocking script from a sighash preimage.
Sourcepub fn estimate_unlock_length(&self) -> usize
pub fn estimate_unlock_length(&self) -> usize
Estimate the byte length of the unlocking script.
Sourcepub fn decode(script: &LockingScript) -> Result<PushDrop, ScriptError>
pub fn decode(script: &LockingScript) -> Result<PushDrop, ScriptError>
Decode a PushDrop locking script, recovering the embedded data fields.
Supports both lock positions:
- Before:
<pubkey> OP_CHECKSIG <fields...> [<sig>] OP_2DROP... - After:
<fields...> OP_2DROP... <pubkey> OP_CHECKSIG
Defaults to Before (matching TS SDK default).
Sourcepub fn decode_with_position(
script: &LockingScript,
position: LockPosition,
) -> Result<PushDrop, ScriptError>
pub fn decode_with_position( script: &LockingScript, position: LockPosition, ) -> Result<PushDrop, ScriptError>
Decode with explicit lock position.
Trait Implementations§
Source§impl ScriptTemplateLock for PushDrop
impl ScriptTemplateLock for PushDrop
Source§fn lock(&self) -> Result<LockingScript, ScriptError>
fn lock(&self) -> Result<LockingScript, ScriptError>
Create a PushDrop locking script using the configured lock position.