Skip to content

Commit 59e58c0

Browse files
committed
first commit
0 parents  commit 59e58c0

10 files changed

Lines changed: 152 additions & 0 deletions

File tree

.github/setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ln -s $PWD/bitcoin-28.0/bin/* /usr/local/bin/
2+
mkdir -p ~/.bitcoin
3+
4+
cat <<EOF > ~/.bitcoin/bitcoin.conf
5+
[regtest]
6+
regtest=1
7+
rpcuser=user
8+
rpcpassword=password
9+
rpcport=18332
10+
EOF
11+
12+
echo $(bitcoin-cli --version)

.github/workflows/main.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Run Setup Script
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Trigger on pushes to the main branch
7+
8+
jobs:
9+
bitcoin-setup:
10+
runs-on: ubuntu-latest # Use the latest Ubuntu environment
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4 # Check out the repository code
15+
16+
- name: Cache Bitcoin Core
17+
id: cache-bitcoin
18+
uses: actions/cache@v3
19+
with:
20+
path: |
21+
bitcoin-28.0
22+
bitcoin-28.0-x86_64-linux-gnu.tar.gz
23+
key: bitcoin-core-28.0
24+
25+
- name: Setup Bitcoin Core
26+
run: |
27+
if [ "${{ steps.cache-bitcoin.outputs.cache-hit }}" != 'true' ]; then
28+
wget https://bitcoincore.org/bin/bitcoin-core-28.0/bitcoin-28.0-x86_64-linux-gnu.tar.gz
29+
tar -xzvf bitcoin-28.0-x86_64-linux-gnu.tar.gz
30+
fi
31+
sudo bash .github/setup.sh
32+
33+
- name: Start bitcoind in regtest mode
34+
run: |
35+
bitcoind -regtest -daemon
36+
echo "Waiting for bitcoind to be ready..."
37+
38+
# Wait for bitcoind to start (max 30s)
39+
for i in {1..30}; do
40+
if bitcoin-cli -regtest getblockchaininfo > /dev/null 2>&1; then
41+
echo "✅ bitcoind is ready!"
42+
break
43+
fi
44+
echo "Still waiting for bitcoind..."
45+
sleep 1
46+
done
47+
48+
- name: 01.sh - Verify Wallet Creation
49+
run: |
50+
chmod +x submission/01.sh
51+
WALLET=$(submission/01.sh)
52+
if [[ "$WALLET" == *"btrustwallet"* ]]; then
53+
echo "✅ Success: Wallet creation passed!"
54+
else
55+
echo "❌ Error: Wallet creation failed!"
56+
exit 1
57+
fi
58+
59+
- name: 02.sh - Verify Redeem Script
60+
run: |
61+
chmod +x submission/02.sh
62+
SCRIPT=$(submission/02.sh)
63+
REDEEM_SCRIPT=522102da2f10746e9778dd57bd0276a4f84101c4e0a711f9cfd9f09cde55acbdd2d1912102bfde48be4aa8f4bf76c570e98a8d287f9be5638412ab38dede8e78df82f33fa352ae
64+
if [[ "$SCRIPT" == "$REDEEM_SCRIPT" ]]; then
65+
echo "✅ Success: Redeem Script verification passed!"
66+
else
67+
echo "❌ Error: Redeem Script verification failed!"
68+
exit 1
69+
fi
70+
71+
- name: 03.sh - Verify P2SH Segwit Script
72+
run: |
73+
chmod +x submission/03.sh
74+
SCRIPT=$(submission/03.sh)
75+
EXPECTED=2NByn92W1vH5oQC1daY69F5sU7PEStKKQBR
76+
if [[ "$SCRIPT" == "$EXPECTED" ]]; then
77+
echo "✅ Success: P2SH Segwit Script verification passed!"
78+
else
79+
echo "❌ Error: P2SH Segwit Script verification failed!"
80+
exit 1
81+
fi
82+
83+
- name: 04.sh - Verify CLTV Script
84+
run: |
85+
chmod +x submission/04.sh
86+
SCRIPT=$(submission/04.sh)
87+
EXPECTED_OUTPUT=0420cd2459b17576a9141e51fcdc14be9a148bb0aaec9197eb47c83776fb88ac
88+
if [[ "$SCRIPT" == "$EXPECTED_OUTPUT" ]]; then
89+
echo "✅ Success: CLTV Script verification passed!"
90+
else
91+
echo "❌ Error: CLTV Script verification failed!"
92+
exit 1
93+
fi
94+
95+
- name: 05.sh - Verify CSV Script
96+
run: |
97+
chmod +x submission/05.sh
98+
SCRIPT=$(submission/05.sh)
99+
EXPECTED_OUTPUT=029600b27576a9141e51fcdc14be9a148bb0aaec9197eb47c83776fb88ac
100+
if [[ "$SCRIPT" == "$EXPECTED_OUTPUT" ]]; then
101+
echo "✅ Success: CSV Script verification passed!"
102+
else
103+
echo "❌ Error: CSV Script verification failed!"
104+
exit 1
105+
fi

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Btrust Builders: LBCLI Week Five Exercises
2+
3+
## Instructions
4+
5+
Exercise should be done using Regtest network.
6+
7+
1. Fork this repository.
8+
2. Go to the `Actions` tab and enable github workflow for your repository by clicking `I understand my ...`
9+
10+
<img src="https://github.com/btrust-builders/lbcli-week-5-exercises/blob/main/enable-github-actions.png" width="500" />
11+
12+
3. Clone your fork to your local computer.
13+
4. Add your bitcoin cli commands to the script files: `01.sh to 05.sh` in the `submission` folder. Example:
14+
```sh
15+
$ bitcoin-cli -regtest getblockcount
16+
```
17+
5. Commit and push your changes to the `main` branch of your remote fork.
18+
19+
6. Confirm your forked repository has a green check mark.
20+
21+
<img src="https://github.com/btrust-builders/lbcli-week-5-exercises/blob/main/success.png" width="1000" />
22+
23+
7. Submit your solution to this form: [Google form](https://forms.gle/eDRGAJXpLqRxEExR6).
24+
25+
PS: You can commit and push as often as you like and GitHub Actions will re-evaluate your code every time.
26+
You will need to look through the auto-grader logs (in the "Actions" tab) to see what exactly you got right or wrong.

enable-github-actions.png

47.8 KB
Loading

submission/01.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Create a wallet with the name "btrustwallet".

submission/02.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# What is the redeem script in this transaction
2+
# transaction="020000000121654fa95d5a268abf96427e3292baed6c9f6d16ed9e80511070f954883864b100000000d90047304402201c97b48215f261055e41b765ab025e77a849b349698ed742b305f2c845c69b3f022013a5142ef61db1ff425fbdcdeb3ea370aaff5265eee0956cff9aa97ad9a357e301473044022000a402ec4549a65799688dd531d7b18b03c6379416cc8c29b92011987084e9f402205470e24781509c70e2410aaa6d827aa133d6df2c578e96a496b885584fb039200147522102da2f10746e9778dd57bd0276a4f84101c4e0a711f9cfd9f09cde55acbdd2d1912102bfde48be4aa8f4bf76c570e98a8d287f9be5638412ab38dede8e78df82f33fa352aeffffffff0188130000000000001600142c48d3401f6abed74f52df3f795c644b4398844600000000"

submission/03.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# What is the address of the P2SH script wrapping the witness redeem script in this transaction
2+
# transaction="020000000121654fa95d5a268abf96427e3292baed6c9f6d16ed9e80511070f954883864b100000000d90047304402201c97b48215f261055e41b765ab025e77a849b349698ed742b305f2c845c69b3f022013a5142ef61db1ff425fbdcdeb3ea370aaff5265eee0956cff9aa97ad9a357e301473044022000a402ec4549a65799688dd531d7b18b03c6379416cc8c29b92011987084e9f402205470e24781509c70e2410aaa6d827aa133d6df2c578e96a496b885584fb039200147522102da2f10746e9778dd57bd0276a4f84101c4e0a711f9cfd9f09cde55acbdd2d1912102bfde48be4aa8f4bf76c570e98a8d287f9be5638412ab38dede8e78df82f33fa352aeffffffff0188130000000000001600142c48d3401f6abed74f52df3f795c644b4398844600000000"

submission/04.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Create a CLTV script with a timestamp of 1495584032 and public key below:
2+
# publicKey=02e3af28965693b9ce1228f9d468149b831d6a0540b25e8a9900f71372c11fb277

submission/05.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Create a CSV script that would lock funds until one hundred and fifty blocks had passed
2+
# publicKey=02e3af28965693b9ce1228f9d468149b831d6a0540b25e8a9900f71372c11fb277

success.png

5.85 KB
Loading

0 commit comments

Comments
 (0)