Skip to content

Commit 2029089

Browse files
committed
first commit
0 parents  commit 2029089

7 files changed

Lines changed: 237 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/tests/chain.test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
echo "Running Chain Test..."
4+
chmod +x submission/02.sh
5+
CHAIN=$(submission/02.sh)
6+
echo "Bitcoin chain: $CHAIN"
7+
8+
if [[ "$CHAIN" == "regtest" ]]; then
9+
echo "✅ Chain verification passed!"
10+
exit 0
11+
else
12+
echo "❌ Chain verification failed!"
13+
exit 1
14+
fi

.github/tests/version.test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
echo "Running Bitcoin Version Test..."
4+
BITCOIN_VERSION=$(submission/01.sh)
5+
echo "Bitcoin CLI Version: $BITCOIN_VERSION"
6+
7+
if [[ $BITCOIN_VERSION == *"28"* ]]; then
8+
echo "✅ Success: Bitcoin CLI version"
9+
exit 0
10+
else
11+
echo "❌ Error: Bitcoin CLI version failed"
12+
exit 1
13+
fi

.github/workflows/main.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
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: Verify Bitcoin CLI version
49+
run: |
50+
BITCOIN_VERSION=$(submission/01.sh)
51+
echo "Bitcoin CLI Version: $BITCOIN_VERSION"
52+
53+
if [[ $BITCOIN_VERSION == *"28"* ]]; then
54+
echo "Success: Bitcoin CLI version"
55+
else
56+
echo "Error: Bitcoin CLI version failed"
57+
exit 1
58+
fi
59+
60+
- name: Verify Bitcoin chain
61+
run: |
62+
chmod +x submission/02.sh
63+
CHAIN=$(submission/02.sh)
64+
echo "Bitcoin chain: $CHAIN"
65+
if [[ "$CHAIN" == "regtest" ]]; then
66+
echo "Chain verification passed!"
67+
else
68+
echo "Chain verification failed!"
69+
exit 1
70+
fi
71+
72+
- name: Verify Wallet Creation
73+
run: |
74+
chmod +x submission/03.sh
75+
WALLET=$(submission/03.sh)
76+
if [[ "$WALLET" == *"btrustwallet"* ]]; then
77+
echo "Wallet creation passed!"
78+
else
79+
echo "Wallet creation failed!"
80+
exit 1
81+
fi
82+
83+
- name: Verify Wallet Balance Check
84+
run: |
85+
chmod +x submission/04.sh
86+
BALANCE=$(submission/04.sh)
87+
if [[ "$BALANCE" == "0.00000000" ]]; then
88+
echo "Wallet balance check passed!"
89+
else
90+
echo "Wallet balance check failed!"
91+
exit 1
92+
fi
93+
94+
- name: Verify Legacy Address Generation
95+
run: |
96+
chmod +x submission/05.sh
97+
LEGACY_ADDRESS=$(submission/05.sh)
98+
echo "LEGACY_ADDRESS=$LEGACY_ADDRESS" >> $GITHUB_ENV
99+
if [[ "$LEGACY_ADDRESS" =~ ^[mn][a-km-zA-HJ-NP-Z1-9]{25,34}$ ]]; then
100+
echo "Legacy address generation passed!"
101+
else
102+
echo "Legacy address generation failed!"
103+
exit 1
104+
fi
105+
106+
- name: Verify P2SH Address Generation
107+
run: |
108+
chmod +x submission/06.sh
109+
P2SH_ADDRESS=$(submission/06.sh)
110+
echo "P2SH_ADDRESS=$P2SH_ADDRESS" >> $GITHUB_ENV
111+
if [[ "$P2SH_ADDRESS" =~ ^2[0-9a-zA-Z]{25,34}$ ]]; then
112+
echo "P2SH address generation passed!"
113+
else
114+
echo "P2SH address generation failed!"
115+
exit 1
116+
fi
117+
118+
- name: Verify Native SegWit Address Generation
119+
run: |
120+
chmod +x submission/07.sh
121+
NATIVE_SEGWIT_ADDRESS=$(submission/07.sh)
122+
echo "NATIVE_SEGWIT_ADDRESS=$NATIVE_SEGWIT_ADDRESS" >> $GITHUB_ENV
123+
if [[ "$NATIVE_SEGWIT_ADDRESS" =~ ^bcrt1[ac-hj-np-z02-9]{8,87}$ ]]; then
124+
echo "Native SegWit address generation passed!"
125+
else
126+
echo "Native SegWit address generation failed!"
127+
exit 1
128+
fi
129+
130+
- name: Verify Taproot Address Generation
131+
run: |
132+
chmod +x submission/08.sh
133+
TAPROOT_ADDRESS=$(submission/08.sh)
134+
echo "TAPROOT_ADDRESS=$TAPROOT_ADDRESS" >> $GITHUB_ENV
135+
if [[ "$TAPROOT_ADDRESS" =~ ^bcrt1p[ac-hj-np-z02-9]{8,87}$ ]]; then
136+
echo "Taproot address generation passed!"
137+
else
138+
echo "Taproot address generation failed!"
139+
exit 1
140+
fi
141+
142+
- name: Verify Address Validation
143+
run: |
144+
chmod +x submission/09.sh
145+
VALID=$(submission/09.sh)
146+
if [[ "$VALID" == "false" ]]; then
147+
echo "Address validation passed!"
148+
else
149+
echo "Address validation failed!"
150+
exit 1
151+
fi
152+
153+
- name: Verify Message Signature
154+
run: |
155+
chmod +x submission/10.sh
156+
VALID=$(submission/10.sh)
157+
if [[ "$VALID" == "true" ]]; then
158+
echo "Message verification passed!"
159+
else
160+
echo "Message verification failed!"
161+
exit 1
162+
fi
163+
164+
- name: Verify Taproot Address Using Descriptors
165+
run: |
166+
chmod +x submission/11.sh
167+
ACTUAL_OUTPUT=$(submission/11.sh)
168+
EXPECTED_OUTPUT="bcrt1puuky37nw03r8mzgnmhtvxg2cxxmzvdm5rvn362mtus3rayw6m2zqg5wwca"
169+
if [[ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]]; then
170+
echo "Taproot address verification passed!"
171+
else
172+
echo "Taproot address verification failed!"
173+
exit 1
174+
fi
175+

README.md

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

submission/01.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Write the bitcoin cli command to get the bitcoin node installation version

success.png

5.85 KB
Loading

0 commit comments

Comments
 (0)