From: alex Date: Tue, 28 Jun 2022 17:45:00 +0000 (-0700) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=0d563730eae0ddc5ec8ffdac106829fc3997d145;p=cold ... --- diff --git a/cold-setup b/cold-setup index 06ef97d..4e91bd3 100755 --- a/cold-setup +++ b/cold-setup @@ -171,6 +171,8 @@ multisig_create_interactive() { log_msg "Use bitcoin core to get information on fully formed change descriptors and output result to descriptors.txt:\n\n\tcat change.descriptors | bitcoin-cli -stdin getdescriptorinfo | jq -j '.descriptor' >> descriptors.txt" confirm "confirm change descriptors added to descriptors.txt" + + log_msg "multi-signature descriptors created and saved to descriptors.txt successfully" } network_off() { @@ -394,9 +396,12 @@ usbs() { } usbs_interactive() { + log_msg "make directory to mount usb:\n\n\tmkdir -p $USB_DIRECTORY" + confirm "usb directory $USB_DIRECTORY created" + # export to usbs for((i = 1; i <= $N; i++)); do - log_msg "insert usb drive..." + log_msg "insert usb drive to use for wallet$i..." USB_PATH="`usb_detect`" log_msg "usb drive detected at $USB_PATH" confirm "use usb drive at $USB_PATH?" diff --git a/test/bitcoin_core_start_interactive.tests.sh b/test/bitcoin_core_start_interactive.tests.sh new file mode 100755 index 0000000..4cf761c --- /dev/null +++ b/test/bitcoin_core_start_interactive.tests.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euo pipefail + +source setup.sh + +mkdir "$TEST_DIR" +cd "$TEST_DIR" + +(echo "Y" | bitcoin_core_start_interactive > result 2>&1) +EXPECTED=$'start bitcoin core:\n\n\tbitcoind --daemonwait' +assert "$EXPECTED" "$( result 2>&1) +EXPECTED=$'stop bitcoin core:\n\n\tbitcoin-cli stop' +assert "$EXPECTED" "$( result 2>&1) +EXPECTED=$'\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...\n\n\nfailed...' +assert "$EXPECTED" "$( result 2>&1) +cat > expected << EOF +Creating multi-signature descriptors... +create output file 'main.descriptors': + + echo -n "wsh(sortedmulti(3," > main.descriptors + + +added descriptors from wallet1 to main.descriptors + + bitcoin-cli -rpcwallet=wallet1 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == false)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> main.descriptors + + +added descriptors from wallet2 to main.descriptors + + bitcoin-cli -rpcwallet=wallet2 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == false)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> main.descriptors + + +added descriptors from wallet3 to main.descriptors + + bitcoin-cli -rpcwallet=wallet3 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == false)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> main.descriptors + + +added descriptors from wallet4 to main.descriptors + + bitcoin-cli -rpcwallet=wallet4 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == false)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> main.descriptors + + +added descriptors from wallet5 to main.descriptors + + bitcoin-cli -rpcwallet=wallet5 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == false)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> main.descriptors + + +added descriptors from wallet6 to main.descriptors + + bitcoin-cli -rpcwallet=wallet6 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == false)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> main.descriptors + + +added descriptors from wallet7 to main.descriptors + + bitcoin-cli -rpcwallet=wallet7 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == false)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> main.descriptors + + +finish formatting for main.descriptors: + + echo "))" >> main.descriptors + + +Use bitcoin core to get information on fully formed descriptors and output result to descriptors.txt: + + cat main.descriptors | bitcoin-cli -stdin getdescriptorinfo | jq -j '.descriptor' >> descriptors.txt + + +create output file 'change.descriptors': + + echo -n "wsh(sortedmulti(3," > change.descriptors + + +added change descriptors from wallet1 to change.descriptors + + bitcoin-cli -rpcwallet=wallet1 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == true)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> change.descriptors + + +added change descriptors from wallet2 to change.descriptors + + bitcoin-cli -rpcwallet=wallet2 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == true)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> change.descriptors + + +added change descriptors from wallet3 to change.descriptors + + bitcoin-cli -rpcwallet=wallet3 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == true)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> change.descriptors + + +added change descriptors from wallet4 to change.descriptors + + bitcoin-cli -rpcwallet=wallet4 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == true)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> change.descriptors + + +added change descriptors from wallet5 to change.descriptors + + bitcoin-cli -rpcwallet=wallet5 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == true)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> change.descriptors + + +added change descriptors from wallet6 to change.descriptors + + bitcoin-cli -rpcwallet=wallet6 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == true)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> change.descriptors + + +added change descriptors from wallet7 to change.descriptors + + bitcoin-cli -rpcwallet=wallet7 listdescriptors | jq -j '.descriptors | map(select(.desc | startswith("wpkh"))) | map(select(.internal == true)) | map(.desc | ltrimstr("wpkh(")) | .[] | split(")") | .[0]' >> change.descriptors + + +finish formatting for change.descriptors: + + echo "))" >> change.descriptors + + +Format descriptors.txt to be ready to append change descriptors: + + echo -n ',{"desc": "' >> descriptors.txt + + +Use bitcoin core to get information on fully formed change descriptors and output result to descriptors.txt: + + cat change.descriptors | bitcoin-cli -stdin getdescriptorinfo | jq -j '.descriptor' >> descriptors.txt +EOF +assert "$( result 2>&1) +EXPECTED=$'shut off networking:\n\n\tnmcli networking off' +assert "$EXPECTED" "$( result 2>&1) +cat > expected << EOF +make directory to mount usb: + + mkdir -p .data/.usb + + +insert usb drive to use for wallet1... +usb drive detected at /dev/sdzzzzz + + +wipe filesystem on /dev/sdzzzzz + + wipefs -a /dev/sdzzzzz + + +format usb device for encryption: + + cryptsetup luksFormat --type luks2 /dev/sdzzzzz + + +open encrypted drive: + + cryptsetup luksOpen /dev/sdzzzzz cold-usb + + +fill drive with zeros: + + dd if=/dev/zero of=/dev/mapper/cold-usb + + +make filesystem on usb drive: + + mkfs.ext4 /dev/mapper/cold-usb + + +mount usb drive: + + mount /dev/mapper/cold-usb .data/.usb + + +dump descriptors for wallet1: + + bitcoin-cli -named -rpcwallet=wallet1 listdescriptors private=true > wallet1.descriptors + + +copy descriptors for wallet1 to .data/.usb: + + cp wallet1.descriptors .data/.usb/ + + +copy multi-signature descriptors to .data/.usb: + + cp descriptors.txt .data/.usb/ + + +verify integrity sum of copied files matches: + + b2sum wallet1.descriptors .data/.usb/wallet1.descriptors descriptors.txt .data/.usb/descriptors.txt + + +shred wallet1.descriptors: + + shred -u wallet1.descriptors + + +unmount usb drive: + + umount .data/.usb + + +eject device: + + eject /dev/mapper/cold-usb + + +insert usb drive to use for wallet2... +usb drive detected at /dev/sdzzzzz + + +wipe filesystem on /dev/sdzzzzz + + wipefs -a /dev/sdzzzzz + + +format usb device for encryption: + + cryptsetup luksFormat --type luks2 /dev/sdzzzzz + + +open encrypted drive: + + cryptsetup luksOpen /dev/sdzzzzz cold-usb + + +fill drive with zeros: + + dd if=/dev/zero of=/dev/mapper/cold-usb + + +make filesystem on usb drive: + + mkfs.ext4 /dev/mapper/cold-usb + + +mount usb drive: + + mount /dev/mapper/cold-usb .data/.usb + + +dump descriptors for wallet2: + + bitcoin-cli -named -rpcwallet=wallet2 listdescriptors private=true > wallet2.descriptors + + +copy descriptors for wallet2 to .data/.usb: + + cp wallet2.descriptors .data/.usb/ + + +copy multi-signature descriptors to .data/.usb: + + cp descriptors.txt .data/.usb/ + + +verify integrity sum of copied files matches: + + b2sum wallet2.descriptors .data/.usb/wallet2.descriptors descriptors.txt .data/.usb/descriptors.txt + + +shred wallet2.descriptors: + + shred -u wallet2.descriptors + + +unmount usb drive: + + umount .data/.usb + + +eject device: + + eject /dev/mapper/cold-usb + + +insert usb drive to use for wallet3... +usb drive detected at /dev/sdzzzzz + + +wipe filesystem on /dev/sdzzzzz + + wipefs -a /dev/sdzzzzz + + +format usb device for encryption: + + cryptsetup luksFormat --type luks2 /dev/sdzzzzz + + +open encrypted drive: + + cryptsetup luksOpen /dev/sdzzzzz cold-usb + + +fill drive with zeros: + + dd if=/dev/zero of=/dev/mapper/cold-usb + + +make filesystem on usb drive: + + mkfs.ext4 /dev/mapper/cold-usb + + +mount usb drive: + + mount /dev/mapper/cold-usb .data/.usb + + +dump descriptors for wallet3: + + bitcoin-cli -named -rpcwallet=wallet3 listdescriptors private=true > wallet3.descriptors + + +copy descriptors for wallet3 to .data/.usb: + + cp wallet3.descriptors .data/.usb/ + + +copy multi-signature descriptors to .data/.usb: + + cp descriptors.txt .data/.usb/ + + +verify integrity sum of copied files matches: + + b2sum wallet3.descriptors .data/.usb/wallet3.descriptors descriptors.txt .data/.usb/descriptors.txt + + +shred wallet3.descriptors: + + shred -u wallet3.descriptors + + +unmount usb drive: + + umount .data/.usb + + +eject device: + + eject /dev/mapper/cold-usb + + +insert usb drive to use for wallet4... +usb drive detected at /dev/sdzzzzz + + +wipe filesystem on /dev/sdzzzzz + + wipefs -a /dev/sdzzzzz + + +format usb device for encryption: + + cryptsetup luksFormat --type luks2 /dev/sdzzzzz + + +open encrypted drive: + + cryptsetup luksOpen /dev/sdzzzzz cold-usb + + +fill drive with zeros: + + dd if=/dev/zero of=/dev/mapper/cold-usb + + +make filesystem on usb drive: + + mkfs.ext4 /dev/mapper/cold-usb + + +mount usb drive: + + mount /dev/mapper/cold-usb .data/.usb + + +dump descriptors for wallet4: + + bitcoin-cli -named -rpcwallet=wallet4 listdescriptors private=true > wallet4.descriptors + + +copy descriptors for wallet4 to .data/.usb: + + cp wallet4.descriptors .data/.usb/ + + +copy multi-signature descriptors to .data/.usb: + + cp descriptors.txt .data/.usb/ + + +verify integrity sum of copied files matches: + + b2sum wallet4.descriptors .data/.usb/wallet4.descriptors descriptors.txt .data/.usb/descriptors.txt + + +shred wallet4.descriptors: + + shred -u wallet4.descriptors + + +unmount usb drive: + + umount .data/.usb + + +eject device: + + eject /dev/mapper/cold-usb + + +insert usb drive to use for wallet5... +usb drive detected at /dev/sdzzzzz + + +wipe filesystem on /dev/sdzzzzz + + wipefs -a /dev/sdzzzzz + + +format usb device for encryption: + + cryptsetup luksFormat --type luks2 /dev/sdzzzzz + + +open encrypted drive: + + cryptsetup luksOpen /dev/sdzzzzz cold-usb + + +fill drive with zeros: + + dd if=/dev/zero of=/dev/mapper/cold-usb + + +make filesystem on usb drive: + + mkfs.ext4 /dev/mapper/cold-usb + + +mount usb drive: + + mount /dev/mapper/cold-usb .data/.usb + + +dump descriptors for wallet5: + + bitcoin-cli -named -rpcwallet=wallet5 listdescriptors private=true > wallet5.descriptors + + +copy descriptors for wallet5 to .data/.usb: + + cp wallet5.descriptors .data/.usb/ + + +copy multi-signature descriptors to .data/.usb: + + cp descriptors.txt .data/.usb/ + + +verify integrity sum of copied files matches: + + b2sum wallet5.descriptors .data/.usb/wallet5.descriptors descriptors.txt .data/.usb/descriptors.txt + + +shred wallet5.descriptors: + + shred -u wallet5.descriptors + + +unmount usb drive: + + umount .data/.usb + + +eject device: + + eject /dev/mapper/cold-usb + + +insert usb drive to use for wallet6... +usb drive detected at /dev/sdzzzzz + + +wipe filesystem on /dev/sdzzzzz + + wipefs -a /dev/sdzzzzz + + +format usb device for encryption: + + cryptsetup luksFormat --type luks2 /dev/sdzzzzz + + +open encrypted drive: + + cryptsetup luksOpen /dev/sdzzzzz cold-usb + + +fill drive with zeros: + + dd if=/dev/zero of=/dev/mapper/cold-usb + + +make filesystem on usb drive: + + mkfs.ext4 /dev/mapper/cold-usb + + +mount usb drive: + + mount /dev/mapper/cold-usb .data/.usb + + +dump descriptors for wallet6: + + bitcoin-cli -named -rpcwallet=wallet6 listdescriptors private=true > wallet6.descriptors + + +copy descriptors for wallet6 to .data/.usb: + + cp wallet6.descriptors .data/.usb/ + + +copy multi-signature descriptors to .data/.usb: + + cp descriptors.txt .data/.usb/ + + +verify integrity sum of copied files matches: + + b2sum wallet6.descriptors .data/.usb/wallet6.descriptors descriptors.txt .data/.usb/descriptors.txt + + +shred wallet6.descriptors: + + shred -u wallet6.descriptors + + +unmount usb drive: + + umount .data/.usb + + +eject device: + + eject /dev/mapper/cold-usb + + +insert usb drive to use for wallet7... +usb drive detected at /dev/sdzzzzz + + +wipe filesystem on /dev/sdzzzzz + + wipefs -a /dev/sdzzzzz + + +format usb device for encryption: + + cryptsetup luksFormat --type luks2 /dev/sdzzzzz + + +open encrypted drive: + + cryptsetup luksOpen /dev/sdzzzzz cold-usb + + +fill drive with zeros: + + dd if=/dev/zero of=/dev/mapper/cold-usb + + +make filesystem on usb drive: + + mkfs.ext4 /dev/mapper/cold-usb + + +mount usb drive: + + mount /dev/mapper/cold-usb .data/.usb + + +dump descriptors for wallet7: + + bitcoin-cli -named -rpcwallet=wallet7 listdescriptors private=true > wallet7.descriptors + + +copy descriptors for wallet7 to .data/.usb: + + cp wallet7.descriptors .data/.usb/ + + +copy multi-signature descriptors to .data/.usb: + + cp descriptors.txt .data/.usb/ + + +verify integrity sum of copied files matches: + + b2sum wallet7.descriptors .data/.usb/wallet7.descriptors descriptors.txt .data/.usb/descriptors.txt + + +shred wallet7.descriptors: + + shred -u wallet7.descriptors + + +unmount usb drive: + + umount .data/.usb + + +eject device: + + eject /dev/mapper/cold-usb +EOF +assert "$( result 2>&1) +cat > expected << EOF +clean up wallet files: + + find ~/.bitcoin -name "wallet.dat" -exec shred -u {} \; +EOF +assert "$( result 2>&1) +cat > expected << EOF +Creating 7 wallets... +create wallet1: + bitcoin-cli -named createwallet wallet_name=wallet1 descriptors=true + + + +create wallet2: + bitcoin-cli -named createwallet wallet_name=wallet2 descriptors=true + + + +create wallet3: + bitcoin-cli -named createwallet wallet_name=wallet3 descriptors=true + + + +create wallet4: + bitcoin-cli -named createwallet wallet_name=wallet4 descriptors=true + + + +create wallet5: + bitcoin-cli -named createwallet wallet_name=wallet5 descriptors=true + + + +create wallet6: + bitcoin-cli -named createwallet wallet_name=wallet6 descriptors=true + + + +create wallet7: + bitcoin-cli -named createwallet wallet_name=wallet7 descriptors=true +EOF +assert "$(