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::Witness
required 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§
- Struct for deposit script that commits Citrea address to be deposited into onchain.
- Struct for scripts that only includes a CHECKSIG
- Struct for scripts that do not conform to any other type of SpendableScripts
- Struct for scripts that reveal a preimage of a OP_HASH160 and verify it against the given hash in the 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.
- 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. - 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§
- 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 SpendableScript
is cast into a concreteScriptKind
to generate a witness, the trait object can be used to generate the script_buf.
Functions§
- Extracts the committed data from the witness. Note: The function is hardcoded for winternitz_log_d = 4 currently, will not work for others.
- Extracts the committed data from the witness. Note: The function is hardcoded for winternitz_log_d = 4 currently, will not work for others.