Skip to content

updated exercises

updated exercises #9

Workflow file for this run

name: Run Setup Script
on:
push:
branches:
- main # Trigger on pushes to the main branch
jobs:
bitcoin-setup:
runs-on: ubuntu-latest # Use the latest Ubuntu environment
steps:
- name: Checkout repository
uses: actions/checkout@v4 # Check out the repository code
- name: Cache Bitcoin Core
id: cache-bitcoin
uses: actions/cache@v3
with:
path: |
bitcoin-28.0
bitcoin-28.0-x86_64-linux-gnu.tar.gz
key: bitcoin-core-28.0
- name: Setup Bitcoin Core
run: |
if [ "${{ steps.cache-bitcoin.outputs.cache-hit }}" != 'true' ]; then
wget https://bitcoincore.org/bin/bitcoin-core-28.0/bitcoin-28.0-x86_64-linux-gnu.tar.gz
tar -xzvf bitcoin-28.0-x86_64-linux-gnu.tar.gz
fi
sudo bash .github/setup.sh
- name: Start bitcoind in regtest mode
run: |
bitcoind -regtest -daemon
echo "Waiting for bitcoind to be ready..."
# Wait for bitcoind to start (max 30s)
for i in {1..30}; do
if bitcoin-cli -regtest getblockchaininfo > /dev/null 2>&1; then
echo "✅ bitcoind is ready!"
break
fi
echo "Still waiting for bitcoind..."
sleep 1
done
- name: 01.sh - Verify Wallet Creation
run: |
chmod +x submission/01.sh
WALLET=$(submission/01.sh)
if [[ "$WALLET" == *"builderswallet"* ]]; then
echo "✅ Success: Wallet creation passed!"
else
echo "❌ Error: Wallet creation failed!"
exit 1
fi
- name: 02.sh - Verify Native Segwit Public Key
run: |
chmod +x submission/02.sh
PUB_KEY=$(submission/02.sh)
if [[ "$PUB_KEY" =~ ^(02|03)[a-fA-F0-9]{64}$ ]]; then
echo "✅ Success: Native Segwit Public Key generation passed!"
else
echo "❌ Error: Native Segwit Public Key generation failed!"
exit 1
fi
- name: 03.sh - Verify Multisig P2SH Address Generation
run: |
actual_sha() { printf '%s' "$1" | sha256sum | awk '{print $1}'; }
chmod +x submission/03.sh
P2SH_ADDRESS=$(submission/03.sh)
EXPECTED_SHA=2a8555480b8dc8079d76cc01d493db3f6a2a6fb553cab096ef302aa9a7a786bc
if [[ "$(actual_sha "$P2SH_ADDRESS")" == "$EXPECTED_SHA" ]]; then
echo "✅ Success: Multisig P2SH address generation passed!"
else
echo "❌ Error: Multisig P2SH address generation failed!"
exit 1
fi
- name: 04.sh - Verify 2-of-3 P2SH Address Generation
run: |
actual_sha() { printf '%s' "$1" | sha256sum | awk '{print $1}'; }
chmod +x submission/04.sh
P2SH_ADDRESS=$(submission/04.sh)
EXPECTED_SHA=71c0ecb1f8b049bef69423993d6fa250e5d8f7c0c0d3f2c655ae72d88a09527a
if [[ "$(actual_sha "$P2SH_ADDRESS")" == "$EXPECTED_SHA" ]]; then
echo "✅ Success: 2-of-3 P2SH address generation passed!"
else
echo "❌ Error: 2-of-3 P2SH address generation failed!"
exit 1
fi
- name: 05.sh - Verify Partially Signed Bitcoin Transaction Generation
run: |
actual_sha() { printf '%s' "$1" | sha256sum | awk '{print $1}'; }
chmod +x submission/05.sh
PSBT=$(submission/05.sh)
EXPECTED_SHA=6f04a9b547c740487f68690609e0f48000f200b710ab6f6fd34a122904cc2669
if [[ "$(actual_sha "$PSBT")" == "$EXPECTED_SHA" ]]; then
echo "✅ Success: Partially Signed Bitcoin Transaction generation passed!"
else
echo "❌ Error: Partially Signed Bitcoin Transaction generation failed!"
exit 1
fi
- name: 06.sh - Verify Hash for Partially Signed Bitcoin Transaction
run: |
actual_sha() { printf '%s' "$1" | sha256sum | awk '{print $1}'; }
chmod +x submission/06.sh
HASH=$(submission/06.sh)
EXPECTED_SHA=341883239f3d189fa268f13e798c7da3e4f6f946e48e23ff5168c167b586a900
if [[ "$(actual_sha "$HASH")" == "$EXPECTED_SHA" ]]; then
echo "✅ Success: Hash Verification for Partially Signed Bitcoin Transaction passed!"
else
echo "❌ Error: Hash Verification for Partially Signed Bitcoin Transaction failed!"
exit 1
fi
- name: 07.sh - Verify Total Transaction Output Amount In Satoshis
run: |
actual_sha() { printf '%s' "$1" | sha256sum | awk '{print $1}'; }
chmod +x submission/07.sh
ACTUAL_OUTPUT=$(submission/07.sh)
EXPECTED_SHA=2099a9b5f777e242d1f9e19d27e232cc71e2fa7964fc988a319fce5671ca7f73
if [[ "$(actual_sha "$ACTUAL_OUTPUT")" == "$EXPECTED_SHA" ]]; then
echo "✅ Success: Total Transaction Output Amount In Satoshis Check passed!"
else
echo "❌ Error: Total Transaction Output Amount In Satoshis Check failed!"
exit 1
fi
- name: 08.sh - Verify Receivers Address Partially Signed Bitcoin Transaction
run: |
actual_sha() { printf '%s' "$1" | sha256sum | awk '{print $1}'; }
chmod +x submission/08.sh
ADD=$(submission/08.sh)
EXPECTED_SHA=3ed76037b964b8894ec758ba2da8d152ddd027f299867cc48a54d4ac206c8b86
if [[ "$(actual_sha "$ADD")" == "$EXPECTED_SHA" ]]; then
echo "✅ Success: Address Verification for Partially Signed Bitcoin Transaction passed!"
else
echo "❌ Error: Address Verification for Partially Signed Bitcoin Transaction failed!"
exit 1
fi