Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Created August 7, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinheadmz/25fcd11ec8ba3916830ebc01d888bd7b to your computer and use it in GitHub Desktop.
Save pinheadmz/25fcd11ec8ba3916830ebc01d888bd7b to your computer and use it in GitHub Desktop.
# git fetch origin
# MUST run inside hsd directory
# run old version
git checkout v2.1.3
time=`date +%s`
export HSD_NETWORK=regtest
hsd --prefix=~/.hsd/migrate-test-$time --daemon
sleep 3
# manually generate change addresses
curl http://127.0.0.1:14039/wallet/primary/change -X POST --data '{"account":"default"}'
curl http://127.0.0.1:14039/wallet/primary/change -X POST --data '{"account":"default"}'
curl http://127.0.0.1:14039/wallet/primary/change -X POST --data '{"account":"default"}'
curl http://127.0.0.1:14039/wallet/primary/change -X POST --data '{"account":"default"}'
curl http://127.0.0.1:14039/wallet/primary/change -X POST --data '{"account":"default"}'
# dump wallet backup -- file will have 5 extra RECEIVE address instead of CHANGE
curl http://x:api-key@127.0.0.1:14039 \
-X POST \
--data '{
"method": "dumpwallet",
"params": [ "'$HOME/.hsd/migrate-test-$time/dump-corrupted.txt'" ]
}'
echo "Change addrs:"
cat $HOME/.hsd/migrate-test-$time/dump-corrupted.txt | grep change | wc -l
echo "Receive addrs:"
cat $HOME/.hsd/migrate-test-$time/dump-corrupted.txt | grep label | wc -l
# stop
curl http://127.0.0.1:14037/ \
-H 'Content-Type: application/json' \
-X POST \
--data '{ "method": "stop" }'
# switch to patched updated version
git checkout change-migration
# launch with the migration command
hsd --prefix=~/.hsd/migrate-test-$time --wallet-migrate=0 --daemon
sleep 3
# dump wallet backup -- file will have the 5 CHANGE addresses included
curl http://x:api-key@127.0.0.1:14039 \
-X POST \
--data '{
"method": "dumpwallet",
"params": [ "'$HOME/.hsd/migrate-test-$time/dump-fixed.txt'" ]
}'
echo "Change addrs:"
cat $HOME/.hsd/migrate-test-$time/dump-fixed.txt | grep change | wc -l
echo "Receive addrs:"
cat $HOME/.hsd/migrate-test-$time/dump-fixed.txt | grep label | wc -l
# finish
hsd-cli rpc stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment