This puzzle is designed to test your understanding of Miniscript, and your ability to construct Miniscript policies that match given spending conditions. Miniscript is a powerful tool for expressing Bitcoin scripts in a more human-readable and manageable way.
Design and validate Bitcoin spending conditions using Miniscript Policy for specific spending scenarios.
- Expected Outcome: Participants should produce a valid Miniscript that, when compiled, generates the correct Bitcoin script. This script must satisfy the provided spending conditions. Additionally, participants should generate valid witness to satisfy the spending conditions encoded in the generated script.
We present a handful of spending paths in these broad categories:
-
Single-sig:
- Requiring exactly one signature from public key.
-
Multisig Path:
- Requires
n
signatures fromm
public key multisig setting immediately without delay.
- Requires
-
Timelocked Signature Path:
- Requires
n
signature fromm
public key multisig setting withp
blocks delay.
- Requires
- Basic knowledge of Bitcoin scripting and Miniscript.
- Familiarity with the Bitcoin network, transaction structure, and the concept of spending conditions.
- Clone the repository:
git clone <repository-url>
cd <repository-name>
- Install dependencies:
cargo build
The entry point to the workshop is each of the files in the tests directory. To pass the first stage, you need to create an empty commit and push it to the remote repository.
git commit --allow-empty -m "Pass the first stage"
git push
Study the code in each of the files in the tests directory and fix the bugs. The stage1_bitcoind.rs file contains the test for the first stage. You do not need to run this test, it is run automatically by the CI pipeline. There are comments in the code that will guide you to the solution. When you are done, create a new commit and push it to the remote repository.
git commit -am "Pass the stage"
git push
You should see the logs for your changes in your terminal. Your code will be tested automatically by the CI pipeline. Your changes will be tested against the latest commit in your branch.
You can also run the program manually to test your changes.
cargo test --test <file_name>
For example:
cargo test --test stage2
We have provided you with a minimal bitcoind instance that you can use to test your code. The bitcoind instance is configured to use regtest mode, and it has been pre-configured for you. The src/lib.rs file contains the supporting code for this challenge. DO NOT MODIFY THIS FILE.
-
Problem: Given a description of a Bitcoin transaction's spending conditions, participants are required to construct a corresponding Miniscript representation. The goal is to express the provided spending paths in Miniscript, which, when compiled, results in a Bitcoin script that accurately represents these conditions.
-
Expected Outcome: You should produce a valid Miniscript that, when compiled, generates the correct Bitcoin script. This script must satisfy the provided spending conditions.
-
Validation: The final Miniscript submitted by you will be compiled into a bitcoin script, funds will be locked to an output with that script, And we will test spending the funds using all the spending conditions in the script.