Expand description
§Bitcoin Script Construction
This module provides a collection of builders for creating various Bitcoin
scripts utilized within the Clementine bridge. It defines a SpendableScript
trait, implemented by specific script structures (e.g., CheckSig,
WinternitzCommit, TimelockScript, BaseDepositScript) to standardize
script generation and witness creation.
Each script builder offers:
- A constructor to initialize the script with its specific parameters.
- A method to convert the script structure into a
bitcoin::ScriptBuf. - A method to generate the corresponding
bitcoin::Witnessrequired to spend an output locked with this script.
The module also includes ScriptKind, an enum to differentiate between various
spendable script types, facilitating dynamic dispatch and script management.
Helper functions like extract_winternitz_commits are provided for parsing
specific data committed using witnernitz keys from witness.
Structs§
- Base
Deposit Script - Struct for deposit script that commits Citrea address to be deposited into onchain.
- Check
Sig - Struct for scripts that only includes a CHECKSIG
- Multisig
- Other
Spendable - Struct for scripts that do not conform to any other type of SpendableScripts
- Preimage
Reveal Script - Struct for scripts that reveal a preimage of a OP_HASH160 and verify it against the given hash in the script.
- Replacement
Deposit Script - Struct for deposit script that replaces an old move tx with a replacement deposit (to update bridge design on chain) It commits to the old move txid inside the script.
- Timelock
Script - Struct for scripts that include a relative timelock (by block count) and optionally a CHECKSIG if a pubkey is provided.
Generates a relative timelock script with a given [
XOnlyPublicKey] that CHECKSIG checks the signature against. - Winternitz
Commit - Struct for scripts that commit to a message using Winternitz keys Contains the Winternitz PK, CheckSig PK, message length respectively can contain multiple different Winternitz public keys for different messages
Enums§
Traits§
- Spendable
Script - A trait that marks all script types. Each script has a
generate_script_inputs(eg.WinternitzCommit::generate_script_inputs) function that generates the witness for the script using various arguments. Adyn SpendableScriptis cast into a concreteScriptKindto generate a witness, the trait object can be used to generate the script_buf.
Functions§
- extract_
winternitz_ commits - Extracts the committed data from the witness. Note: The function is hardcoded for winternitz_log_d = 4 currently, will not work for others.
- extract_
winternitz_ commits_ with_ sigs - Extracts the committed data from the witness. Note: The function is hardcoded for winternitz_log_d = 4 currently, will not work for others.
- from_
minimal_ 🔒to_ u32_ le_ bytes - Converts a minimal serialized u32 (trailing zeros removed) to full 4 byte representation