From 9a6314df011ec35ddee9aedc1d3496a45ba46d4a Mon Sep 17 00:00:00 2001 From: CasperDkk Date: Wed, 19 Mar 2025 19:54:47 +0300 Subject: [PATCH 1/3] complete --- submission/test.sh | 59 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/submission/test.sh b/submission/test.sh index 0590d25..c429337 100644 --- a/submission/test.sh +++ b/submission/test.sh @@ -23,17 +23,27 @@ 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" +{ + "name": "btrustwallet" +} + # 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" +{ + "name": "treasurewallet" +} + # 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=bcrt1qyhd2hke3xuyznv8a6wmazyh4d3nhgh4j0qs0kt check_cmd "Address generation" echo "Mining to address: $TREASURE_ADDR" @@ -47,7 +57,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=0.00000000 check_cmd "Balance check" echo "Your starting balance: $BALANCE BTC" @@ -59,16 +69,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=mi4St3bGUYtmiQHYGaJSdYkhqu2VAGAFsp check_cmd "Legacy address generation" -P2SH_ADDR= +P2SH_ADDR=2N2RnaQhwYrc8hy6KGLeFkbxASksR8KTF5H check_cmd "P2SH address generation" -SEGWIT_ADDR= +SEGWIT_ADDR=bcrt1qfy75jj06vcz9jf54c95e76y8rwstw90njnana3 check_cmd "SegWit address generation" -TAPROOT_ADDR= +TAPROOT_ADDR=bcrt1p5ckxqvvtm2ele4fkjccdv8wg9kpszmqy5jkmwu6kznsuas6cfa7sfpk32c check_cmd "Taproot address generation" echo "Your exploration addresses:" @@ -97,11 +107,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=10.00000000 BTC check_cmd "New balance check" echo "Your treasure balance: $NEW_BALANCE BTC" -COLLECTED= +COLLECTED=-40.00000000 BTC check_cmd "Balance calculation" echo "You've collected $COLLECTED BTC in treasures!" @@ -164,37 +174,60 @@ 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=bcrt1pcgq2axzaq804cee7wacl7uyt2njxx6m94ky40kv6qjnugz6e3nws9xyc7z 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= +Address Info: +{ + "address": "bcrt1pcgq2axzaq804cee7wacl7uyt2njxx6m94ky40kv6qjnugz6e3nws9xyc7z", + "scriptPubKey": "5120c200ae985d01df5c673e7771ff708b54e4636b65ad8957d99a04a7c40b598cdd", + "ismine": true, + "solvable": true, + "desc": "tr([05ab1061/86h/1h/0h/0/3]0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#n4nszwdg", + "parent_desc": "tr([05ab1061/86h/1h/0h]tpubDDuQgUketVqrYLyjFEC7GfBwwoVoCRBsY9utgAhjWA1tQwdYqo9Mx2xGAzBR6SdPKuULa5ioFDHWJLnZuveZf3imZzzLuM8oxpHKsYQa5ED/0/*)#tekau5vt", + "iswatchonly": false, + "isscript": true, + "iswitness": true, + "witness_version": 1, + "witness_program": "c200ae985d01df5c673e7771ff708b54e4636b65ad8957d99a04a7c40b598cdd", + "ischange": false, + "timestamp": 1742391261, + "hdkeypath": "m/86h/1h/0h/0/3", + "hdseedid": "0000000000000000000000000000000000000000", + "hdmasterfingerprint": "05ab1061", + "labels": [ + "taproot" + ] +} + 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=0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7 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(0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#sky204a9 echo "Simple descriptor: $SIMPLE_DESCRIPTOR" # STUDENT TASK: Get a proper descriptor with checksum # WRITE YOUR SOLUTION BELOW: -TAPROOT_DESCRIPTOR= +TAPROOT_DESCRIPTOR= tr(0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#sky204a9 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=bcrt1pcgq2axzaq804cee7wacl7uyt2njxx6m94ky40kv6qjnugz6e3nws9xyc7z check_cmd "Address derivation" DERIVED_ADDR=$(echo "$DERIVED_ADDR_RAW" | tr -d '[]" \n\t') echo "Derived quantum vault address: $DERIVED_ADDR" From b9c4ded33d968a9b107c1fb8e2d60f5f0abaefcb Mon Sep 17 00:00:00 2001 From: CasperDkk Date: Wed, 19 Mar 2025 20:44:29 +0300 Subject: [PATCH 2/3] 2nd attempt --- submission/test.sh | 64 ++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/submission/test.sh b/submission/test.sh index c429337..411afb5 100644 --- a/submission/test.sh +++ b/submission/test.sh @@ -22,28 +22,18 @@ 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" -{ - "name": "btrustwallet" -} - # 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" -{ - "name": "treasurewallet" -} - # Generate an address for mining in the treasure wallet # STUDENT TASK: Generate a new address in the treasurewallet # WRITE YOUR SOLUTION BELOW: -TREASURE_ADDR=bcrt1qyhd2hke3xuyznv8a6wmazyh4d3nhgh4j0qs0kt +TREASURE_ADDR=$(bitcoin-cli -regtest -rpcwallet=treasurewallet getnewaddress) check_cmd "Address generation" echo "Mining to address: $TREASURE_ADDR" @@ -57,7 +47,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=0.00000000 +BALANCE=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getbalance) check_cmd "Balance check" echo "Your starting balance: $BALANCE BTC" @@ -69,16 +59,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=mi4St3bGUYtmiQHYGaJSdYkhqu2VAGAFsp +LEGACY_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" legacy) check_cmd "Legacy address generation" -P2SH_ADDR=2N2RnaQhwYrc8hy6KGLeFkbxASksR8KTF5H +P2SH_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" p2sh-segwit) check_cmd "P2SH address generation" -SEGWIT_ADDR=bcrt1qfy75jj06vcz9jf54c95e76y8rwstw90njnana3 +SEGWIT_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" bech32) check_cmd "SegWit address generation" -TAPROOT_ADDR=bcrt1p5ckxqvvtm2ele4fkjccdv8wg9kpszmqy5jkmwu6kznsuas6cfa7sfpk32c +TAPROOT_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" bech32m) check_cmd "Taproot address generation" echo "Your exploration addresses:" @@ -107,11 +97,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=10.00000000 BTC +NEW_BALANCE=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getbalance) check_cmd "New balance check" echo "Your treasure balance: $NEW_BALANCE BTC" -COLLECTED=-40.00000000 BTC +COLLECTED=$(echo "$NEW_BALANCE - $BALANCE" | btc) check_cmd "Balance calculation" echo "You've collected $COLLECTED BTC in treasures!" @@ -122,7 +112,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" @@ -153,7 +143,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" @@ -174,60 +164,38 @@ 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=bcrt1pcgq2axzaq804cee7wacl7uyt2njxx6m94ky40kv6qjnugz6e3nws9xyc7z +NEW_TAPROOT_ADDR=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" 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= -Address Info: -{ - "address": "bcrt1pcgq2axzaq804cee7wacl7uyt2njxx6m94ky40kv6qjnugz6e3nws9xyc7z", - "scriptPubKey": "5120c200ae985d01df5c673e7771ff708b54e4636b65ad8957d99a04a7c40b598cdd", - "ismine": true, - "solvable": true, - "desc": "tr([05ab1061/86h/1h/0h/0/3]0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#n4nszwdg", - "parent_desc": "tr([05ab1061/86h/1h/0h]tpubDDuQgUketVqrYLyjFEC7GfBwwoVoCRBsY9utgAhjWA1tQwdYqo9Mx2xGAzBR6SdPKuULa5ioFDHWJLnZuveZf3imZzzLuM8oxpHKsYQa5ED/0/*)#tekau5vt", - "iswatchonly": false, - "isscript": true, - "iswitness": true, - "witness_version": 1, - "witness_program": "c200ae985d01df5c673e7771ff708b54e4636b65ad8957d99a04a7c40b598cdd", - "ischange": false, - "timestamp": 1742391261, - "hdkeypath": "m/86h/1h/0h/0/3", - "hdseedid": "0000000000000000000000000000000000000000", - "hdmasterfingerprint": "05ab1061", - "labels": [ - "taproot" - ] -} +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=0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7 +INTERNAL_KEY=$(echo "$ADDR_INFO" | jq -r '.desc' | sed -E 's/tr\(\[.*\](.*)\).*/\1/') 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=tr(0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#sky204a9 +SIMPLE_DESCRIPTOR="tr(0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#sky204a9" echo "Simple descriptor: $SIMPLE_DESCRIPTOR" # STUDENT TASK: Get a proper descriptor with checksum # WRITE YOUR SOLUTION BELOW: -TAPROOT_DESCRIPTOR= tr(0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#sky204a9 +TAPROOT_DESCRIPTOR=$(bitcoin-cli -regtest getdescriptorinfo "tr($INTERNAL_KEY)") 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=bcrt1pcgq2axzaq804cee7wacl7uyt2njxx6m94ky40kv6qjnugz6e3nws9xyc7z +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" From aaf12c127813cad29a0b1295cdab9c79ad598db8 Mon Sep 17 00:00:00 2001 From: CasperDkk Date: Thu, 27 Mar 2025 14:18:37 +0300 Subject: [PATCH 3/3] Final changes --- submission/test.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/submission/test.sh b/submission/test.sh index 411afb5..89d600d 100644 --- a/submission/test.sh +++ b/submission/test.sh @@ -23,12 +23,14 @@ 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 @@ -101,7 +103,7 @@ NEW_BALANCE=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getbalance) check_cmd "New balance check" echo "Your treasure balance: $NEW_BALANCE BTC" -COLLECTED=$(echo "$NEW_BALANCE - $BALANCE" | btc) +COLLECTED=$(awk "BEGIN {print $NEW_BALANCE - $BALANCE}") check_cmd "Balance calculation" echo "You've collected $COLLECTED BTC in treasures!" @@ -164,38 +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=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getnewaddress "" bech32m) +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=$(bitcoin-cli -regtest -rpcwallet=btrustwallet getaddressinfo "$NEW_TAPROOT_ADDR") - +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=$(echo "$ADDR_INFO" | jq -r '.desc' | sed -E 's/tr\(\[.*\](.*)\).*/\1/') +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="tr(0aedbaa185bdd2192689d1354ef7441e83b9f0ed1fc6db99362761dc29058bf7)#sky204a9" +SIMPLE_DESCRIPTOR="tr($INTERNAL_KEY)" echo "Simple descriptor: $SIMPLE_DESCRIPTOR" # STUDENT TASK: Get a proper descriptor with checksum # WRITE YOUR SOLUTION BELOW: -TAPROOT_DESCRIPTOR=$(bitcoin-cli -regtest getdescriptorinfo "tr($INTERNAL_KEY)") +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=$(bitcoin-cli -regtest deriveaddresses "$TAPROOT_DESCRIPTOR") +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" @@ -241,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." \ No newline at end of file