It has been some months my working on some bash scripts.
These scripts warp arounf bitcoin-cli rpc calls to parse block and transaction data.
Just give it the trasaction hash or block hash/height
As i wrote some wrappers for blockchain.com APIs, I wanted to get
more or less the same information. I used functions from grondilu's
bitcoin-bash-tools..
Before trying the scripts, one needs have bitcoin-cli, openssl, jq and
bash (v4 or above) installed. Also, that is a very good idea to have bitcoin-cli
set with txindex=1 (otherwise you will need supply the block hash for the
transactions and some addresses will not be coded to base58 from their hex).
The scripts are at https://github.com/mountaineerbr/scripts
There are two scripts, one for getting block information and transaction
hashes in that block, and another to get transaction information by
transaction hash. For example:
Get info of a transaction by its hash id:
$ bitcoin.tx.sh a8bb9571a0667d63eaaaa36f9de87675f0d430e13c916248ded1d13093a77561
The output:
--------
Transaction information
TxId____: a8bb9571a0667d63eaaaa36f9de87675f0d430e13c916248ded1d13093a77561
Hash____: eac5391d9f7b411c7d6cbadb59a38bfa13399c3ecb440573f5f52b8a34001be1
BlkHash_: 0000000000000000000fb6a4d6f5dc7438f91a1bc3988c4f32b4bb8284eed0ec
Time____: 1594156611 2020-07-07T21:16:51Z
BlkTime_: 1594156611 2020-07-07T21:16:51Z
LockTime: 0
Version_: 1
Vsize___: 224
Size____: 414
Weight__: 894
Confirma: 12546
Vins
TxIndex: 44f672f301772cf3e3fc15d424818aae8ed43468deb0cc56550dd9374578b816
Sequenc: 4294967295
VoutNum: 1
Addresses
Number_: 1 Value__: 4.68295
type: witness_v0_scripthash
bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej
Vouts
Number_: 0 Value__: 0.26139693
Addresses
type: scripthash
3KLwdgGf5QLHEW8qjxyv7wFpPMdVCDqu55
Number_: 1 Value__: 0.19883951
Addresses
type: pubkeyhash
1Lv9hU7h86REpDakYy9kpeTfT929b9twM5
Number_: 2 Value__: 4.22231356
Addresses
type: witness_v0_scripthash
bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej
One can parse all transactions from a block (ex: height 400000) using my two scripts, such as:
$ bitcoin.blk.sh -ii 400000 | bitcoin.tx.sh
I have been checking some blockchair parses that try to parse binary blockchain data,
which don't output as much useful information (at least for me, a regular user)
of a transaction as my script do.
The transaction script (bitcoin.tx.sh) is slow because depending on the transaction vins and vouts
it needs query previous transactions, too. This script can take from a fraction of a second
for a simple transaction up to a few seconds to parse a transaction with various in and out vectors.
Transaction from block 400000 and 668385 took approximately 12 minutes and 18 minutes to
parse, respectively with my script (intel i7).
The script (bitcoin.blk.sh) for parsing block data can also decode transaction hex of coinbase.
Decode coinbase from block height 668385:
$ bitcoin.blk.sh -y 668385
bb/BTC.TOP/
And the bitcoin.hx.sh will help you guys encoding and decoding public and private keys
(legacy addresses only), as well as decoding hex strings that you may get from the blockchain.
The scripts contain a help page, print with -h :
https://github.com/mountaineerbr/scripts
Cheers,