Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions submission/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ echo "----------------------------------------"
echo "Create a wallet named 'btrustwallet' to track your Bitcoin exploration"
# STUDENT TASK: Use bitcoin-cli to create a wallet named "btrustwallet"
# WRITE YOUR SOLUTION BELOW:

bitcoin-cli -regtest createwallet "btrustwallet"
check_cmd "Wallet creation"

# Create a second wallet that will hold the treasure
echo "Now, create another wallet called 'treasurewallet' to fund your adventure"
# STUDENT TASK: Create another wallet called "treasurewallet"
# WRITE YOUR SOLUTION BELOW:

bitcoin-cli -regtest createwallet "treasurewallet"
check_cmd "Treasure wallet creation"

# Generate an address for mining in the treasure wallet
# STUDENT TASK: Generate a new address in the treasurewallet
# WRITE YOUR SOLUTION BELOW:
TREASURE_ADDR=
TREASURE_ADDR=$(bitcoin-cli -regtest -rpcwallet=treasurewallet getnewaddress)
check_cmd "Address generation"
echo "Mining to address: $TREASURE_ADDR"

Expand All @@ -47,7 +49,7 @@ echo "-----------------------------------------"
echo "Check your wallet balance to see what resources you have to start"
# STUDENT TASK: Get the balance of btrustwallet
# WRITE YOUR SOLUTION BELOW:
BALANCE=
BALANCE=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getbalance)
check_cmd "Balance check"
echo "Your starting balance: $BALANCE BTC"

Expand All @@ -59,16 +61,16 @@ echo "The treasure hunt requires 4 different types of addresses to collect funds
echo "Generate one of each address type (legacy, p2sh-segwit, bech32, bech32m)"
# STUDENT TASK: Generate addresses of each type
# WRITE YOUR SOLUTION BELOW:
LEGACY_ADDR=
LEGACY_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" legacy)
check_cmd "Legacy address generation"

P2SH_ADDR=
P2SH_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" p2sh-segwit)
check_cmd "P2SH address generation"

SEGWIT_ADDR=
SEGWIT_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" bech32)
check_cmd "SegWit address generation"

TAPROOT_ADDR=
TAPROOT_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" bech32m)
check_cmd "Taproot address generation"

echo "Your exploration addresses:"
Expand Down Expand Up @@ -97,11 +99,11 @@ echo "-------------------------------"
echo "Treasures have been sent to your addresses. Check how much you've collected!"
# STUDENT TASK: Check wallet balance after receiving funds and calculate how much treasure was collected
# WRITE YOUR SOLUTION BELOW:
NEW_BALANCE=
NEW_BALANCE=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getbalance)
check_cmd "New balance check"
echo "Your treasure balance: $NEW_BALANCE BTC"

COLLECTED=
COLLECTED=$(awk "BEGIN {print $NEW_BALANCE - $BALANCE}")
check_cmd "Balance calculation"
echo "You've collected $COLLECTED BTC in treasures!"

Expand All @@ -112,7 +114,7 @@ echo "--------------------------------------------"
echo "To ensure the P2SH vault is secure, verify it's a valid Bitcoin address"
# STUDENT TASK: Validate the P2SH address
# WRITE YOUR SOLUTION BELOW:
P2SH_VALID=
P2SH_VALID=$(bitcoin-cli -regtest validateaddress "$P2SH_ADDR" | jq -r '.isvalid')
check_cmd "Address validation"
echo "P2SH vault validation: $P2SH_VALID"

Expand Down Expand Up @@ -143,7 +145,7 @@ echo "For CI testing, we'll verify the correct message directly:"

# STUDENT TASK: Verify the message
# WRITE YOUR SOLUTION BELOW:
VERIFY_RESULT=
VERIFY_RESULT=$(bitcoin-cli -regtest -rpcwallet=btrustwallet verifymessage "$LEGACY_ADDR" "$SIGNATURE" "$SECRET_MESSAGE")
check_cmd "Message verification"
echo "Message verification result: $VERIFY_RESULT"

Expand All @@ -164,37 +166,37 @@ echo "Create a descriptor for your taproot address and derive the address to ens

# STUDENT TASK: Create a new taproot address
# WRITE YOUR SOLUTION BELOW:
NEW_TAPROOT_ADDR=
NEW_TAPROOT_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress NEW_TAPROOT_ADDR bech32m)
check_cmd "New taproot address generation"
NEW_TAPROOT_ADDR=$(trim "$NEW_TAPROOT_ADDR")

# STUDENT TASK: Get the address info to extract the internal key
# WRITE YOUR SOLUTION BELOW:
ADDR_INFO=
ADDR_INFO=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getaddressinfo $NEW_TAPROOT_ADDR)
check_cmd "Getting address info"

# STUDENT TASK: Extract the internal key (the x-only pubkey) from the descriptor
# WRITE YOUR SOLUTION BELOW:
INTERNAL_KEY=
INTERNAL_KEY=$(echo $ADDR_INFO | jq -r '.desc' | sed -n 's/.*\]\([0-9a-fA-F]*\).*/\1/p')
check_cmd "Extracting key from descriptor"
INTERNAL_KEY=$(trim "$INTERNAL_KEY")

# STUDENT TASK: Create a proper descriptor with just the key
# WRITE YOUR SOLUTION BELOW:
echo "Using internal key: $INTERNAL_KEY"
SIMPLE_DESCRIPTOR=
SIMPLE_DESCRIPTOR="tr($INTERNAL_KEY)"
echo "Simple descriptor: $SIMPLE_DESCRIPTOR"

# STUDENT TASK: Get a proper descriptor with checksum
# WRITE YOUR SOLUTION BELOW:
TAPROOT_DESCRIPTOR=
TAPROOT_DESCRIPTOR=$(bitcoin-cli -regtest getdescriptorinfo $SIMPLE_DESCRIPTOR | jq -r '.descriptor')
check_cmd "Descriptor generation"
TAPROOT_DESCRIPTOR=$(trim "$TAPROOT_DESCRIPTOR")
echo "Taproot treasure map: $TAPROOT_DESCRIPTOR"

# STUDENT TASK: Derive an address from the descriptor
# WRITE YOUR SOLUTION BELOW:
DERIVED_ADDR_RAW=
DERIVED_ADDR_RAW=$(bitcoin-cli -regtest deriveaddresses $TAPROOT_DESCRIPTOR)
check_cmd "Address derivation"
DERIVED_ADDR=$(echo "$DERIVED_ADDR_RAW" | tr -d '[]" \n\t')
echo "Derived quantum vault address: $DERIVED_ADDR"
Expand Down Expand Up @@ -240,4 +242,4 @@ echo "- Validate addresses"
echo "- Work with message signatures"
echo "- Use Bitcoin descriptors"
echo ""
echo "NOTE: This script is specifically designed to work with Bitcoin Core v28."
echo "NOTE: This script is specifically designed to work with Bitcoin Core v28."