I wrote a little bash script that displays the transaction info in json:
#!/usr/bin/env bash
set -e
set -o errexit
function process_block() {
date --rfc-3339=ns
bhash=${1:-$(bitcoin-cli getbestblockhash)}
block=$(bitcoin-cli getblock $bhash)
pbhash=$(echo "$block" | jq -r .previousblockhash)
height=$(echo "$block" | jq -r .height)
echo "height: $height"
nTx=$(echo "$block" | jq -r .nTx)
echo "$nTx transactions"
Tx=$(echo "$block" | jq -r .tx[])
IFS=$'\n'
for txhash in $Tx; do
txjson=$(bitcoin-cli getrawtransaction $txhash 1 $bhash)
addresses=$(echo "$txjson" | jq -r '.vout[].scriptPubKey | select(.type == "pubkeyhash") | .addresses | .[]')
for a in $addresses; do
if [[ $a == ${2} ]]; then
echo "$txjson"
fi
done
done
process_block $pbhash ${2}
}
process_block "" ${1}
Can be used as:
./btc.sh 1...
I ran bitcoind in pruned mode to get a blockchain. I downloaded the latest snapshot like this:
aria2c http://utxosets.blob.core.windows.net/public/$(curl https://raw.githubusercontent.com/btcpayserver/btcpayserver-docker/master/contrib/FastSync/utxo-sets | grep -F mainnet | tail -n 1 | grep -Po utxo.*)
The only problem is that it is really slow. It takes about a minute to process about 1k transactions. Any advice how the things could be speed up?