Last active
April 12, 2020 06:27
-
-
Save buzzkillb/878ff03068f141b01fa8afdcc92d9a25 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 | |
#for Denarius cryptocurrency - denarius.io, just change denariusd to your favorite coin daemon | |
#change all denariusd to denarius.daemon for snap daemon use | |
#bitcointalk thread - https://bitcointalk.org/index.php?topic=5238747 | |
#create rawa.txt with txid and vouts for all inputs, then remove all extra spaces and newlines to rawb.txt | |
#rawa.txt put txid and vout | |
#rawb.txt remove extra space and put createtransaction begin text | |
#rawc.txt remove last comma and add rest of rawtx info creating the full raw transaction line | |
# | |
#txfee - fee you want to use | |
#minimuminputs - regroup as long as address has minimum of this number | |
#minimumbalance - only regroup if the balance is minimum of this number | |
# | |
#search for password and change to your password | |
#chmod +x dedust.sh | |
#to run | |
#./dedust.sh | |
txfee=0.00010001 | |
minimuminputs=1 | |
minimumbalance=0.00100000 | |
#get list of all addresses from listunspent | |
denariusd walletpassphrase "password" 500 | |
denariusd listunspent | jq -r '.[].address' > addresslistall.txt | |
#deduplicated list of addresses | |
awk '!seen[$0]++' addresslistall.txt > addresslistdedup.txt | |
#run loop through each address from deduplication list | |
while IFS= read -r address; do | |
#count how many inputs in the address | |
denariusd walletpassphrase "password" 500 | |
txcount=($(denariusd listunspent | jq --arg ADDRESS "$address" '[.[] | select(.address==$ADDRESS) | .txid ]| length ')) | |
#if address has minimuminputs then do this | |
if [ "$txcount" -gt "$minimuminputs" ]; then | |
echo "dedust addy: "$address | |
sumdust=($(denariusd listunspent | jq --arg ADDRESS "$address" '.[] | select(.address==$ADDRESS) | .amount | tonumber ' | jq -s add | awk {' printf "%.8f",$1'})) | |
subtractfee=$(echo "$sumdust - $txfee" | bc) | |
echo "denarii dust: "$sumdust | |
if [ 1 -eq "$(echo "${minimumbalance} < ${subtractfee}" | bc)" ] | |
then | |
echo "Gonna send eet. corombies19" | |
rm rawa.txt rawb.txt rawc.txt | |
denariusd walletpassphrase "password" 500 | |
denariusd listunspent | jq --arg ADDRESS "$address" '.[] | select(.address==$ADDRESS) | .txid,.vout ' | ( | |
while read txid; do | |
read vout | |
echo '{"txid":'$txid',"vout":'$vout'},' >> rawa.txt | |
done | |
) | |
tr -d ' \t\n\r\f' <rawa.txt > rawb.txt | |
#add all input balances together | |
sumdust=($(denariusd listunspent | jq --arg ADDRESS "$address" '.[] | select(.address==$ADDRESS) | .amount | tonumber ' | jq -s add | awk {' printf "%.8f",$1'})) | |
sed -i '1s/^/createrawtransaction [/' rawb.txt | |
#remove last comma | |
sed '$ s/,$//g' rawb.txt > rawc.txt | |
echo '] {"'$address'":'$subtractfee'}' >> rawc.txt | |
#store rawtransaction | |
createrawtransaction=$(head -1 rawc.txt) | |
echo $createrawtransaction | |
#createrawtransaction | |
echo "creating raw transaction" | |
signrawtransaction=($(denariusd $createrawtransaction)) | |
echo $signrawtransaction | |
#signrawtransaction | |
echo "sign raw transaction" | |
sendrawtransaction=($(denariusd signrawtransaction $signrawtransaction | jq -r '.hex')) | |
echo $sendrawtransaction | |
#sendrawtransaction | |
echo "send raw transaction" | |
denariusd sendrawtransaction $sendrawtransaction | |
echo "combined dust minus fee: "$subtractfee | |
fi | |
fi | |
done < addresslistdedup.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment