0

So, I'm using Bitcoin Core RPC client version v22.0.0 and Bitcoin Core version v22.0.0.

To get the block with height 1, I call the API like this:

bitcoin-cli -datadir=/Users/dennis/Bitcoin getblock \
00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 2

You see this block only contains the coinbase transaction. If you check the vout section you won't see any address.

"vin": [
  {
    "coinbase": "04ffff001d0104",
    "sequence": 4294967295
  }
],
"vout": [
  {
    "value": 50.00000000,
    "n": 0,
    "scriptPubKey": {
      "asm": "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG",
      "hex": "410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac",
      "type": "pubkey"
    }
  }
]

However, If you make the same call but for a newer block, for example with height 700,000:

bitcoin-cli -datadir=/Users/dennis/Bitcoin getblock \         
0000000000000000000590fc0f3eba193a278534220b2b37e9849e1a770ca959 2

You will see the address of the coinbase transaction:

"vin": [
  {
    "coinbase": "0360ae0a2cfabe6d6d078b52bc69cf0982356d3eb439efe5489aee2c74da629dcc1a8b50a309cc0800100000000212030400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005008a1c0000",
    "txinwitness": [
      "0000000000000000000000000000000000000000000000000000000000000000"
    ],
    "sequence": 0
  }
],
"vout": [
  {
    "value": 6.40388640,
    "n": 0,
    "scriptPubKey": {
      "asm": "0 f3b2d6544de521b5c617fc83ca6d13854f29a8a5",
      "hex": "0014f3b2d6544de521b5c617fc83ca6d13854f29a8a5",
      "address": "bc1q7wedv4zdu5smt3shljpu5mgns48jn299mukymc",
      "type": "witness_v0_keyhash"
    }
  },

Questions:

  • It is something related to bitcoin-cli version?
  • If so, It's posible to get the coinbase address for older blocks building a parser and directly parsing blk000.dat files?
  • If it's not possible, how blockchain.com shows the coinbase address for all blocks?

2 Answers 2

1

If you look at this block in a blockchain explorer such as blockchair, it shows the transaction as

{
    "txid": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
    "hash": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
    "version": 1,
    "size": 134,
    "vsize": 134,
    "weight": 536,
    "locktime": 0,
    "vin": [
        {
            "coinbase": "04ffff001d0104",
            "sequence": 4294967295
        }
    ],
    "vout": [
        {
            "value": 50,
            "n": 0,
            "scriptPubKey": {
                "asm": "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG",
                "hex": "410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac",
                "reqSigs": 1,
                "type": "pubkey",
                "addresses": [
                    "12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX"
                ]
            }
        }
    ]
}

Blockchair shows an address, but Bitcoin Core doesn't.

Note that "Bitcoin address" is an invention that I believe was intended to make it easier for recipients to provide senders with information needed by the sender to construct a transaction script.

Transaction data doesn't ever actually include an address.

Bitcoin core doesn't present an address, probably because they weren't in use at the time P2PK transactions were used. I guess addresses came into use with P2PKH transactions.

Note that many blockchain explorers have their own way of dreiving addresses from more exotic forms of payment such as multisignature payments. Not all software agrees about whether such transaction types can be represented in the form of an address.

3
  • This is actually a recent change. Bitcoin Core for a long time used to show P2PKH addresses for P2PK outputs, because historically, before different address types existed, P2PKH were also used as a "key id" in addition to the "shorthand for specific scriptPubKey". This is not considered a historic mistake, and fixed in recent versions. Oct 12, 2021 at 9:54
  • Now I have a better idea about it. However, it's still not clear for me if I built my own parser to read the raw data from blk.dat files, could I derive the addresses of these transactions? I mean, is this data actually in the blockchain or not?
    – Dennis
    Oct 12, 2021 at 10:36
  • 1
    @Dennis, if Blockchair's software can do it, so can yours. The data is in the scripts in the transaction outputs, or for input addresses, the data is in the outputs of earlier transactions referred to by the vin txid and offset. You'll need to work out how to categorise the transaction output type and work out the address algorithm for each type. Oct 12, 2021 at 14:07
1

The coinbase output (the destination of the mining reward) is freely decided by the miner.

In early block, this destination was Pay to Pubkey(P2PK). Since P2PK is not assigned an address, no address is shown.

The coinbase transaction in the 700,000 height shows the address because the destination is P2WPKH.

Your Answer

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

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