There's a verbose output of the very first block info:

bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 2

  "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
  "confirmations": 790168,
  "height": 0,
  "version": 1,
  "versionHex": "00000001",
  "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
  "time": 1231006505,
  "mediantime": 1231006505,
  "nonce": 2083236893,
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
  "nTx": 1,
  "nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
  "strippedsize": 285,
  "size": 285,
  "weight": 1140,
  "tx": [
      "txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "hash": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "version": 1,
      "size": 204,
      "vsize": 204,
      "weight": 816,
      "locktime": 0,
      "vin": [
          "coinbase": "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
          "sequence": 4294967295
      "vout": [
          "value": 50.00000000,
          "n": 0,
          "scriptPubKey": {
            "asm": "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG",
            "desc": "pk(04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f)#vlz6ztea",
            "hex": "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac",
            "type": "pubkey"
      "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"

As far as I understood, we see here one transaction (in "tx": [...]), on 50 BTC, the transaction id (txid). Having this data, how can I get the input/output address using e.g. the same bitcoin-cli or RPC API equivalent (according to the doc)?

Does coinbase in vin means Block Reward? How from vout (or wherever else) get the address we usually see (1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa)?

I tried bitcoin-cli getrawtransaction ... (as here) but the output is unclear to me.

If bitcoin-cli is unable to provide that - then any other way?

1 Answer 1


how can I get the input/output address using e.g. the same bitcoin-cli

The general answer is:

To get addresses relating to inputs you need to fetch the locking scripts (scriptPubkey) from the referenced outputs of the referenced transactions.

To retrieve transactions by ID, I believe you have to have transaction indexing turned on in bitcoin.conf. It will take a while to construct an index of transaction-IDs. I expect you need pruning turned off. In the worst case you have to repeat the Initial Block Download process.

For two separate reasons, your example's input does not refer to an actual previous transaction

  1. It is a coinbase transaction, their input is not a real input.
  2. Your block is the first, there are no earlier blocks.

So there is no source address.

Does coinbase in vin means Block Reward?

In this case it refers to the arbitrary data that a coinbase transaction has in place of the unlocking script. This is the first transaction in a block and is therefore a coinbase transaction.

BIP-34 specifies that the first item in this arbitrary data is a push of the block-height. Older blocks don't have that but all recent ones do. The remainder is whatever the miner wanted to record.

The amount of available block reward is only indirectly determined. It depends only on block height. It is affected by the halving interval, which is fixed.

The miner doesn't have to collect all or any of the available block reward. The amount they choose to claim is in part of the vout value. For understandable reasons, miners usually claim the full amount available but sometimes people don't - probably mostly as a result of a mistake.

How from vout (or wherever else) get the address

You (or Bitcoin core) have to calculate it from the relevant locking script.

Addresses have well-specified or de-facto address derivations for only some types of transaction output, not all.

In some cases there is no address, or no universally agreed address, or no meaningful address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.