<blockquote>
<p><strong>how can I get the input/output address using e.g. the same bitcoin-cli</strong></p>
</blockquote>
<p>The general answer is:</p>
<p>To get addresses relating to inputs you need to fetch the locking scripts (scriptPubkey) from the referenced outputs of the referenced transactions.</p>
<p>To retrieve transactions by ID, I believe you have to have transaction indexing turned on in <code>bitcoin.conf</code>. 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.</p>
<p>For two separate reasons, your example's input does not refer to an actual previous transaction</p>
<ol>
<li>It is a coinbase transaction, their input is not a real input.</li>
<li>Your block is the first, there are no earlier blocks.</li>
</ol>
<p>So there is no source address.</p>
<blockquote>
<p><strong>Does coinbase in vin means Block Reward?</strong></p>
</blockquote>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>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 <code>vout</code> value. For understandable reasons, miners usually claim the full amount available but sometimes people don't - probably mostly as a result of a mistake.</p>
<blockquote>
<p><strong>How from vout (or wherever else) get the address</strong></p>
</blockquote>
<p>You (or Bitcoin core) have to calculate it from the relevant locking script.</p>
<ul>
<li><a href="https://bitcoin.stackexchange.com/q/112338/13866">How to get &quot;From&quot; and &quot;To&quot; addresses from bitcoin transaction using the command line?</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/107944/13866">How can I get the destination address from raw transaction data?</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/89207/13866">How to get input address and amount from vin using bitcoin core rpc</a></li>
<li><a href="https://bitcoin.stackexchange.com/q/14151/13866">Deriving the Bitcoin address from the raw block script</a></li>
</ul>
<p>Addresses have well-specified or de-facto address derivations for only some types of transaction output, not all.</p>
<p>In some cases there is no address, or no universally agreed address, or no meaningful address.</p>

CC BY-SA 4.0
2023-09-01T19:42:20.243Z
2023-09-01T20:04:53.867Z
2023-09-01T20:04:53.867Z
RedGrittyBrick
<p>There's a verbose output of <a href="https://www.blockchain.com/explorer/blocks/btc/0" rel="nofollow noreferrer">the very first block</a> info:</p>
<pre><code>bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 2

{
  &quot;hash&quot;: &quot;000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f&quot;,
  &quot;confirmations&quot;: 790168,
  &quot;height&quot;: 0,
  &quot;version&quot;: 1,
  &quot;versionHex&quot;: &quot;00000001&quot;,
  &quot;merkleroot&quot;: &quot;4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b&quot;,
  &quot;time&quot;: 1231006505,
  &quot;mediantime&quot;: 1231006505,
  &quot;nonce&quot;: 2083236893,
  &quot;bits&quot;: &quot;1d00ffff&quot;,
  &quot;difficulty&quot;: 1,
  &quot;chainwork&quot;: &quot;0000000000000000000000000000000000000000000000000000000100010001&quot;,
  &quot;nTx&quot;: 1,
  &quot;nextblockhash&quot;: &quot;00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048&quot;,
  &quot;strippedsize&quot;: 285,
  &quot;size&quot;: 285,
  &quot;weight&quot;: 1140,
  &quot;tx&quot;: [
    {
      &quot;txid&quot;: &quot;4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b&quot;,
      &quot;hash&quot;: &quot;4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b&quot;,
      &quot;version&quot;: 1,
      &quot;size&quot;: 204,
      &quot;vsize&quot;: 204,
      &quot;weight&quot;: 816,
      &quot;locktime&quot;: 0,
      &quot;vin&quot;: [
        {
          &quot;coinbase&quot;: &quot;04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73&quot;,
          &quot;sequence&quot;: 4294967295
        }
      ],
      &quot;vout&quot;: [
        {
          &quot;value&quot;: 50.00000000,
          &quot;n&quot;: 0,
          &quot;scriptPubKey&quot;: {
            &quot;asm&quot;: &quot;04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG&quot;,
            &quot;desc&quot;: &quot;pk(04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f)#vlz6ztea&quot;,
            &quot;hex&quot;: &quot;4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac&quot;,
            &quot;type&quot;: &quot;pubkey&quot;
          }
        }
      ],
      &quot;hex&quot;: &quot;01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000&quot;
    }
  ]
}
</code></pre>
<p>As far as I understood, we see here one transaction (in <code>&quot;tx&quot;: [...]</code>), on 50 BTC, the transaction id (<code>txid</code>). Having this data, how can I get the input/output address using e.g. the same <code>bitcoin-cli</code> or RPC API equivalent (according to the <a href="https://developer.bitcoin.org/reference/rpc/" rel="nofollow noreferrer">doc</a>)?</p>
<p>Does <code>coinbase</code> in <code>vin</code> means Block Reward?
How from <code>vout</code> (or wherever else) get <a href="https://www.blockchain.com/explorer/addresses/BTC/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa" rel="nofollow noreferrer">the address</a> we usually see (<code>1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa</code>)?</p>
<p>I tried <code>bitcoin-cli getrawtransaction ...</code> (as <a href="https://bitcoin.stackexchange.com/questions/112338/how-to-get-from-and-to-addresses-from-bitcoin-transaction-using-the-command">here</a>) but the output is unclear to me.</p>
<p>If <code>bitcoin-cli</code> is unable to provide that - then any other way?</p>

<bitcoin-core><bitcoin-cli>
Bitcoin core: How to get transactions data having block?
Putnik
# Bitcoin core: How to get transactions data having block?

(Asked by: username_0 on 2023-09-01)

There's a verbose output of [the very first block](https://www.blockchain.com/explorer/blocks/btc/0) 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](https://developer.bitcoin.org/reference/rpc/))?

Does `coinbase` in `vin` means Block Reward?
How from `vout` (or wherever else) get [the address](https://www.blockchain.com/explorer/addresses/BTC/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa) we usually see (`1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa`)?

I tried `bitcoin-cli getrawtransaction ...` (as [here](https://bitcoin.stackexchange.com/questions/112338/how-to-get-from-and-to-addresses-from-bitcoin-transaction-using-the-command)) but the output is unclear to me.

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

**Tags:** bitcoin-core, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2023-09-01. Score: 0 | Accepted answer

> **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.

* [How to get "From" and "To" addresses from bitcoin transaction using the command line?](https://bitcoin.stackexchange.com/q/112338/13866)
* [How can I get the destination address from raw transaction data?](https://bitcoin.stackexchange.com/q/107944/13866)
* [How to get input address and amount from vin using bitcoin core rpc](https://bitcoin.stackexchange.com/q/89207/13866)
* [Deriving the Bitcoin address from the raw block script](https://bitcoin.stackexchange.com/q/14151/13866)

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.


---

