Skip to main content

ScriptTemplateUnlock

Trait ScriptTemplateUnlock 

Source
pub trait ScriptTemplateUnlock {
    // Required methods
    fn sign(&self, preimage: &[u8]) -> Result<UnlockingScript, ScriptError>;
    fn estimate_length(&self) -> Result<usize, ScriptError>;
}
Expand description

Trait for creating unlocking scripts (analogous to TS SDK ScriptTemplateUnlock).

Implementors produce an UnlockingScript and can estimate its byte length for fee calculation purposes.

Required Methods§

Source

fn sign(&self, preimage: &[u8]) -> Result<UnlockingScript, ScriptError>

Sign a transaction input and produce an unlocking script.

The preimage is the sighash preimage bytes that the caller computes from the transaction context. The template signs this directly.

Source

fn estimate_length(&self) -> Result<usize, ScriptError>

Estimate the byte length of the unlocking script (for fee calculation).

Implementors§