Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Created June 8, 2021 00:09
Show Gist options
  • Save pinheadmz/75e8c8d79dc5a9c18c00a545c4a03b07 to your computer and use it in GitHub Desktop.
Save pinheadmz/75e8c8d79dc5a9c18c00a545c4a03b07 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
time=`date +%s`
export HSD_NETWORK=regtest
hsd --prefix=~/.hsd/bip39passphrase-test-$time --daemon
sleep 2
PHRASE="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
PS="secret123"
BIP39PS="menace"
hsw-cli mkwallet --id=original --mnemonic="$PHRASE" > /dev/null
hsw-cli mkwallet --id=encrypted --mnemonic="$PHRASE" --passphrase="$PS" > /dev/null
hsw-cli mkwallet --id=bip39 --mnemonic="$PHRASE" --bip39-passphrase="$BIP39PS" > /dev/null
hsw-cli mkwallet --id=bip39encrypted --mnemonic="$PHRASE" --bip39-passphrase="$BIP39PS" --passphrase="$PS" > /dev/null
echo " -- "
echo "Should have different xprv"
echo "original"
hsw-cli master --id=original | jq .key.xprivkey
echo "bip39"
hsw-cli master --id=bip39 | jq .key.xprivkey
echo " -- "
echo "Should have same address"
echo "original"
hsw-cli --id=original account get default | jq .receiveAddress
echo "encrypted"
hsw-cli --id=encrypted account get default | jq .receiveAddress
echo "Should have same address, but different than original & encrypted"
echo "bip39"
hsw-cli --id=bip39 account get default | jq .receiveAddress
echo "bip39encrypted"
hsw-cli --id=bip39encrypted account get default | jq .receiveAddress
hsw-rpc selectwallet original > /dev/null
hsd-rpc generatetoaddress 10 `hsw-rpc getnewaddress` > /dev/null
hsw-rpc selectwallet encrypted > /dev/null
hsd-rpc generatetoaddress 10 `hsw-rpc getnewaddress` > /dev/null
hsw-rpc selectwallet bip39 > /dev/null
hsd-rpc generatetoaddress 10 `hsw-rpc getnewaddress` > /dev/null
hsw-rpc selectwallet bip39encrypted > /dev/null
hsd-rpc generatetoaddress 10 `hsw-rpc getnewaddress` > /dev/null
echo " -- "
hsw-cli lock --id=original > /dev/null
hsw-cli lock --id=bip39 > /dev/null
hsw-cli lock --id=encrypted > /dev/null
hsw-cli lock --id=bip39encrypted > /dev/null
echo "Should send without error"
hsw-cli send --id=original --value=1 --address=`hsw-rpc getnewaddress` | jq '.hash'
hsw-cli send --id=bip39 --value=1 --address=`hsw-rpc getnewaddress` | jq '.hash'
echo "Should require wallet-unlocking passphrase"
hsw-cli send --id=encrypted --value=1 --address=`hsw-rpc getnewaddress`
hsw-cli send --id=bip39encrypted --value=1 --address=`hsw-rpc getnewaddress`
hsw-cli send --id=encrypted --value=1 --address=`hsw-rpc getnewaddress` --passphrase="$PS" | jq '.hash'
hsw-cli send --id=bip39encrypted --value=1 --address=`hsw-rpc getnewaddress` --passphrase="$PS" | jq '.hash'
hsd-rpc stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment