0

Consider the following coinbase transaction:

https://www.blockchain.com/btc/tx/d70ae1131d433b655d0faeae1db4efa15bb4138f1e38e60a53073a58ea1dcc34

How we can retrieve the recipient address, i.e. 1JAL1WRvwbJqWWd1Ktks4Q89zCeUYSQM12 using the output field of the RPC command below:

bitcoin-cli getrawtransaction d70ae1131d433b655d0faeae1db4efa15bb4138f1e38e60a53073a58ea1dcc34 1


"vout": [
    {
      "value": 50.12000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "0400d0ade32217e076945e0946ef7bed72d9aea035aa8891e4bf0749ae6e24f8a7d3ea56efafe472ac3943dbed3af7c093729720ac9ab04e8eba09286e3a00fe41 OP_CHECKSIG",
        "hex": "410400d0ade32217e076945e0946ef7bed72d9aea035aa8891e4bf0749ae6e24f8a7d3ea56efafe472ac3943dbed3af7c093729720ac9ab04e8eba09286e3a00fe41ac",
        "type": "pubkey"
      }
    }
  ],

For non-coinbase transactions, the output filed contains the value of addresses.

bitcoin-cli getrawtransaction bd20f46a4337ab787f6fbd036e9f4d65c7ae67d21cc6f9013162e783384d877c 1

"vout": [
    {
      "value": 1.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 53c32617316707bb8ba4e1546fa8c32bd212c86d OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a91453c32617316707bb8ba4e1546fa8c32bd212c86d88ac",
        "address": "18dts6fXXA7jVKfYMBpsFqx7iZCELCfDpk",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 58.97000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 37fdd890381f9965d620fc3d0c9fa3e511cb1449 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a91437fdd890381f9965d620fc3d0c9fa3e511cb144988ac",
        "address": "1674G5SSZAb7h4unJMjdxfgNwo71vxgGQg",
        "type": "pubkeyhash"
      }
    }
  ],

1 Answer 1

3

Observe that the type of the output is:

"type": "pubkey"

Pay-to-Public-Key (P2PK) outputs do not have addresses. They pay directly to a public key rather than the hash of the public key, as the name suggests. Bitcoin addresses encode public key hashes, for example, addresses starting with a 1 are known as Pay-to-Public-Key-Hash (P2PKH) addresses and encode the Ripemd-160(sha-256(public key)).

See my other answer here for the same sort of question.

1
  • Thank you for your answer. I'll follow the steps provided in the wiki to see how services like blockchain.com or blockchair.com pull out such addresses.
    – sci9
    Jan 2, 2022 at 5:02

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.