Bitcoin’s decentralized nature allows anyone to inspect transaction details and address balances on the blockchain. For those seeking a more technical and in-depth approach, bitcoin-cli
offers powerful tools to achieve this. In this article, we’ll explore how to use bitcoin-cli
to check the balance of any Bitcoin address and delve into transaction details, using the example address 397qgNDydQ4Ui6Ah4FurnxmmUDcDHsyJEv
.
Checking the Balance of a Bitcoin Address
To check the balance of a Bitcoin address, you can use the scantxoutset
command. This command scans the blockchain’s UTXO set for outputs associated with a specific address.
Using scantxoutset
Run the following command to check the balance of address 397qgNDydQ4Ui6Ah4FurnxmmUDcDHsyJEv
:
$ bitcoin-cli scantxoutset start '["addr(397qgNDydQ4Ui6Ah4FurnxmmUDcDHsyJEv)"]'
This command returns all UTXOs associated with the address and provides the total balance.
Delving into Transaction Details
Understanding transaction details requires knowing the transaction ID (txid
) and the output index (vout
).
1. Using getrawtransaction
If you have a transaction ID, use the getrawtransaction
command to fetch the transaction’s raw data:
$ bitcoin-cli getrawtransaction "txid" true
Replace “txid” with the actual transaction ID. This command outputs the raw transaction data in a readable JSON format, showing inputs, outputs, amounts, and more. Let’s use the “txid” from the previous output as an example:
$ bitcoin-cli getrawtransaction "8c5cfd8a5a9068501e0901b270a73c9017b7978e2c8987105a1676ae5d73af2d" true { "txid": "8c5cfd8a5a9068501e0901b270a73c9017b7978e2c8987105a1676ae5d73af2d", "hash": "2bc272cb95347a08e04dad2a908a14c96fc516cd74ac8729f03965f4303440d1", "version": 1, "size": 246, "vsize": 165, "weight": 657, "locktime": 0, "vin": [ { "txid": "5ef55a3b7e303d3056dfdc1d953bc8c0fda7c7bbe115fe3906a841c9d9c2bd24", "vout": 1, "scriptSig": { "asm": "0014a04c2c26ef49d11a72aae51428fc0ca7563bbca1", "hex": "160014a04c2c26ef49d11a72aae51428fc0ca7563bbca1" }, "txinwitness": [ "3044022029db31efead0515ad9552fc59bcd12b32cf39ea5f9a0384b00eadc2215fa0e67022009bad746eb6bde5bee713aa8db75e26c2c736533f07717aa98df7c70be4f663d01", "030373b1fec380338da210dbdacd25024f1182ef91ff482cc27ccea45a6dc2fe2b" ], "sequence": 4294967293 } ], "vout": [ { "value": 1.00000000, "n": 0, "scriptPubKey": { "asm": "0 29228f39ef0f3819de68bb913edfaa414b745374", "desc": "addr(bc1q9y3g7w00puupnhnghwgnaha2g99hg5m5ul8l68)#eda9fgzt", "hex": "001429228f39ef0f3819de68bb913edfaa414b745374", "address": "bc1q9y3g7w00puupnhnghwgnaha2g99hg5m5ul8l68", "type": "witness_v0_keyhash" } }, { "value": 437.25916527, "n": 1, "scriptPubKey": { "asm": "OP_HASH160 517aba585a3100a500fcdd6c8bcb73fdf00f45f3 OP_EQUAL", "desc": "addr(397qgNDydQ4Ui6Ah4FurnxmmUDcDHsyJEv)#rkgyy7ad", "hex": "a914517aba585a3100a500fcdd6c8bcb73fdf00f45f387", "address": "397qgNDydQ4Ui6Ah4FurnxmmUDcDHsyJEv", "type": "scripthash" } } ], "hex": "0100000000010124bdc2d9c941a80639fe15e1bbc7a7fdc0c83b951ddcdf56303d307e3b5af55e0100000017160014a04c2c26ef49d11a72aae51428fc0ca7563bbca1fdffffff0200e1f5050000000016001429228f39ef0f3819de68bb913edfaa414b7453746f89442e0a00000017a914517aba585a3100a500fcdd6c8bcb73fdf00f45f38702473044022029db31efead0515ad9552fc59bcd12b32cf39ea5f9a0384b00eadc2215fa0e67022009bad746eb6bde5bee713aa8db75e26c2c736533f07717aa98df7c70be4f663d0121030373b1fec380338da210dbdacd25024f1182ef91ff482cc27ccea45a6dc2fe2b00000000", "blockhash": "00000000000000000004c9e55bc79c14918f8f0439d4b11e5929a4c5a0011f5c", "confirmations": 20039, "time": 1693638398, "blocktime": 1693638398 }