Created
July 4, 2020 02:22
-
-
Save buzzkillb/b65f4520ef4d2420a168335219c13437 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
##Destruction.sh - checks balances and removes any addresses from dumpwallet.txt with 0 inputs | |
#"dumpwallet dumpwallet.txt" and put in same directory as this script | |
#then run this script | |
#might want staking=0 in denarius.conf until everything is done | |
#stop wallet, move wallet.dat to wallet.bak, open wallet, "importwallet cleaned.txt" | |
#wait for rescan, "tail -f debug.log" to watch | |
#once your balance shows up, stop wallet, staking=1, start wallet | |
#DONE | |
#requires config.conf and rpc.sh from https://github.com/buzzkillb/bash-denariusrpc | |
### THIS IS GOING TO PUT PRIVKEYS into a TEXTFILE, disconnecto internet or something when running ###### | |
##### ALWAYS BACKUP wallet.dat ###### | |
. config.conf | |
. rpc.sh | |
minimuminputs=0 | |
#First Part - Find all addresses with a balance and put into balance.txt | |
#deduplicate addresses | |
unspentaddresses=$(rpc_listunspent | jq -r '.[].address' | awk '!seen[$0]++') | |
while IFS= read -r | |
do | |
printf '%s\n' $REPLY | |
#count how many inputs per address | |
txcount=$(rpc_listunspent | jq --arg ADDRESS "$REPLY" '[.[] | select(.address == $ADDRESS) | .txid ] | length') | |
#echo "$txcount" | |
#if address has minimuminputs then do this | |
if [ "$txcount" -gt "$minimuminputs" ]; then | |
#Put any addresses with 1 input or more into balance.txt list | |
echo $REPLY >> balance.txt | |
fi | |
done <<< "$unspentaddresses" | |
#Second Part | |
#scan through balance.txt and take any line from dumpwallet.txt and put into cleaned.txt | |
while IFSBALANCE=, read -r input1; do | |
echo "$input1" | |
grep "${input1}" dumpwallet.txt >> cleaned.txt | |
done <balance.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment