Skip to content

Instantly share code, notes, and snippets.

@jsarenik
Created September 16, 2020 15:17
Show Gist options
  • Save jsarenik/92056bc43983dfdfe766210f05dbc2d6 to your computer and use it in GitHub Desktop.
Save jsarenik/92056bc43983dfdfe766210f05dbc2d6 to your computer and use it in GitHub Desktop.
This is a way to get rid of the dust on Bitcoin

Find the transaction you want to get rid of:

listunspent

Note the "address" (for later), "txid" and "vout" lines.

createrawtransaction \
  '[{"txid": "THE_TXID", "vout": VOUT}]' \
  '[{ "tb1qryakg74re8an5yc99nsznj4f7t94rghk6m986l": 0}]'

Note the result as RAWTX. The address used in this raw transaction is not important. 0 is sent to it. All goes to mining fees. But it has to be a valid address.

Now get the private key for the "address":

dumpprivkey "address"

Note the result as PRIVKEY.

signrawtransactionwithkey RAWTX '["PRIVKEY"]'

Note the "hex" result as SIGNEDRAWTX and send it:

sendrawtransaction SIGNEDRAWTX
#!/bin/sh -e
DUSTADDR=tb1qay0y44753qzu8sg4yc2uuqj2t38hfemvgktdpn
bc() {
bitcoin-cli -testnet $*
}
{
echo "Now find the bad dust transaction you want to get rid of."
echo "Select its \"txid\" value so that you can paste it next."
echo "---------------------------------------------------------"
bc listunspent | jq .[] | grep '^{\|^}\|txid\|amount'
} | less
printf "Paste the txid of dust transaction: "
read dusttx
RES=$(bc listunspent | jq "(.[] | select(.txid == \"$dusttx\"))")
ADDR=$(echo $RES | jq -r .address)
TXID=$(echo $RES | jq -r .txid)
VOUT=$(echo $RES | jq .vout)
RAWTX=$(bc createrawtransaction \
"[{\"txid\":\"$TXID\",\"vout\":$VOUT}]" \
"[{\"$DUSTADDR\":0}]")
test "$?" = "0" || exit 1
PRIVK=$(bc dumpprivkey $ADDR)
SIGNEDRAWTX=$(bc signrawtransactionwithkey $RAWTX "[\"$PRIVK\"]" | jq -r .hex)
bc sendrawtransaction $SIGNEDRAWTX
@jsarenik
Copy link
Author

Can also be found at bin.bublina.eu.org or even via Tor at the onion address.

@jsarenik
Copy link
Author

For reference, also see my issue on Peter Todd's dust-b-gone.

@jsarenik
Copy link
Author

@jsarenik
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment