Last active
December 3, 2022 07:13
-
-
Save accerqueira/c4e1fd15791ef6f5b29543eb16e9d893 to your computer and use it in GitHub Desktop.
Export private keys from bitcoin-wallet (de.schildbach.wallet)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
WALLET=${1} | |
sudo apt-get install maven openjfx >/dev/null | |
WALLET_DEC=$(mktemp) | |
cleanup() { | |
err=$? | |
rm -f ${WALLET_DEC} | |
cd $(dirs -l -0) && dirs -c > /dev/null | |
trap '' EXIT INT TERM | |
exit $err | |
} | |
sig_cleanup() { | |
trap '' EXIT # some shells will call EXIT after the INT handler | |
false # sets $? | |
cleanup | |
} | |
trap cleanup EXIT | |
trap sig_cleanup INT QUIT TERM | |
openssl enc -d -aes-256-cbc -md md5 -a -in ${WALLET} > ${WALLET_DEC} | |
git clone --depth 1 -b v0.14.4 https://github.com/bitcoinj/bitcoinj.git >/dev/null 2>&1 | |
pushd bitcoinj/tools > /dev/null | |
./wallet-tool dump --wallet ${WALLET_DEC} --dump-privkeys | grep -o -P '(?<=priv WIF=)\w*' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
CLI=${1:-bitcoin-cli} | |
while read -r KEY || [[ -n "${KEY}" ]]; do | |
${CLI} importprivkey '"'${KEY}'"' '""' 'false' | |
done | |
echo "Done!" | |
echo "Now you need to restart bitcoind -rescan" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, @crmarques!
@hsachdevah, does @crmarques fix works for you?