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" } } ],

sci9
  • 107
  • 6

1 Answers1

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.

meshcollider
  • 11,815
  • 4
  • 25
  • 53
  • 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 02 '22 at 05:02