<p>Transaction inputs are listed via the txid and the outputs index. In the case of your example, you'd need to make a second call:</p>
<p><code>bitcoin-cli gettransaction c5355fe45f785f14f15b3e41894e21083978e9e78ed23b7a3a00f0061ec735a5</code></p>
<p>And then look at the output at the index <code>n: 1</code> to find the address in question.</p>

CC BY-SA 4.0
2022-02-10T11:21:46.870Z
Thank you ! You can see this transaction here https://www.blockchain.com/btc/tx/2c33baf70886d48cc3259ca1dc5d3dde974394f476d5faa2673cb6e35721fd83     . .  The problem is that I am unable to see the "from address" in my output. I can make a second call to the txid in VIN, but I am trying to avoid that. The output is the receiver address. It has the other 2 addresses. 1 address is the actual receiver and the second address should be where it returns the remaining balance
Abdul Rehman Rajput
CC BY-SA 4.0
2023-09-12T19:05:19.120Z
error message:
No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)

Why do you need a wallet to get info about transactions that do NOT include addresses you own?

If you have a wallet, then the error message is `Invalid or non-wallet transaction id`. So this answer is expected to wor for your transactions only.
Putnik
CC BY-SA 4.0
2023-09-13T23:31:19.070Z
@Putnik if you have `txindex=1` set then you can query any transaction, otherwise it would indeed work for your wallet's transactions only.
chytrik
CC BY-SA 4.0
2023-09-14T11:41:56.517Z
I do have `txindex=1 ` and all 800k+ blocks are on my disk. Maybe, something else?
Putnik
CC BY-SA 4.0
2023-09-15T18:31:47.297Z
@Putnik it would be best to open a new question, rather than discuss this in the comments of a somewhat unrelated question.
chytrik
CC BY-SA 4.0
2022-02-10T07:18:41.760Z
2022-02-10T07:18:41.760Z
chytrik
<p>I am scanning the bitcoin blocks and looking for transactions that involve my list of addresses. This is more like a wallet hosting service. I need the &quot;From&quot; and &quot;To&quot; addresses used in the transaction.</p>
<p>I am using the &quot;bitcoin-cli gettransaction&quot; method to get transaction details.</p>
<p>I know that VIN block should contain the sender addresses and VOUT block should be the receiving addresses. I can see the VOUT block with receiving addresses, but I can't see the &quot;From&quot; addresses in VIN block.</p>
<p>How can I get the &quot;from&quot; and &quot;To&quot; address in bitcoin transaction?</p>
<p>Here is a data sample,</p>
<pre><code>     &quot;vin&quot;: [
    {
      &quot;txid&quot;: &quot;c5355fe45f785f14f15b3e41894e21083978e9e78ed23b7a3a00f0061ec735a5&quot;,
      &quot;vout&quot;: 1,
      &quot;scriptSig&quot;: {
        &quot;asm&quot;: &quot;&quot;,
        &quot;hex&quot;: &quot;&quot;
      },
      &quot;txinwitness&quot;: [
        &quot;3045022100f5ee5cb40a06419c55eb2de549ee97daf77a8e2588d3e0dd800cade7605d4c760220453533f8ba09165076f4a252dc9336f2d4040a3b071754441805c94df555a5ce01&quot;,
        &quot;02f6e670a3fcb90b40bb66fa550b5202ae8c9b50d69fcc1ffb5377b022f7f629fd&quot;
      ],
      &quot;sequence&quot;: 4294967293
    }
  ],
  &quot;vout&quot;: [
    {
      &quot;value&quot;: 0.00309202,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;OP_DUP OP_HASH160 2f8f5127a4f8234552e6ab2107303d1761e6ddbe OP_EQUALVERIFY OP_CHECKSIG&quot;,
        &quot;hex&quot;: &quot;76a9142f8f5127a4f8234552e6ab2107303d1761e6ddbe88ac&quot;,
        &quot;address&quot;: &quot;15LUSrgQ1qFtgx5237AskkjeMcX4bpHfBH&quot;,
        &quot;type&quot;: &quot;pubkeyhash&quot;
      }
    },
    {
      &quot;value&quot;: 0.06857278,
      &quot;n&quot;: 1,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;0 83e6911dcb2f412677376c6a70a01655dd534457&quot;,
        &quot;hex&quot;: &quot;001483e6911dcb2f412677376c6a70a01655dd534457&quot;,
        &quot;address&quot;: &quot;bc1qs0nfz8wt9aqjvaehd348pgqk2hw4x3zhupv0xw&quot;,
        &quot;type&quot;: &quot;witness_v0_keyhash&quot;
      }
    }
  ]

</code></pre>

<bitcoin-core><bitcoin-cli>
How to get "From" and "To" addresses from bitcoin transaction using the command line?
Abdul Rehman Rajput
# How to get "From" and "To" addresses from bitcoin transaction using the command line?

(Asked by: username_0 on 2022-02-10)

I am scanning the bitcoin blocks and looking for transactions that involve my list of addresses. This is more like a wallet hosting service. I need the "From" and "To" addresses used in the transaction.

I am using the "bitcoin-cli gettransaction" method to get transaction details.

I know that VIN block should contain the sender addresses and VOUT block should be the receiving addresses. I can see the VOUT block with receiving addresses, but I can't see the "From" addresses in VIN block.

How can I get the "from" and "To" address in bitcoin transaction?

Here is a data sample,

```
     "vin": [
    {
      "txid": "c5355fe45f785f14f15b3e41894e21083978e9e78ed23b7a3a00f0061ec735a5",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "3045022100f5ee5cb40a06419c55eb2de549ee97daf77a8e2588d3e0dd800cade7605d4c760220453533f8ba09165076f4a252dc9336f2d4040a3b071754441805c94df555a5ce01",
        "02f6e670a3fcb90b40bb66fa550b5202ae8c9b50d69fcc1ffb5377b022f7f629fd"
      ],
      "sequence": 4294967293
    }
  ],
  "vout": [
    {
      "value": 0.00309202,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 2f8f5127a4f8234552e6ab2107303d1761e6ddbe OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9142f8f5127a4f8234552e6ab2107303d1761e6ddbe88ac",
        "address": "15LUSrgQ1qFtgx5237AskkjeMcX4bpHfBH",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 0.06857278,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 83e6911dcb2f412677376c6a70a01655dd534457",
        "hex": "001483e6911dcb2f412677376c6a70a01655dd534457",
        "address": "bc1qs0nfz8wt9aqjvaehd348pgqk2hw4x3zhupv0xw",
        "type": "witness_v0_keyhash"
      }
    }
  ]

```

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


---

## 1 answers

### Answer by username_1 on 2022-02-10. Score: 1

Transaction inputs are listed via the txid and the outputs index. In the case of your example, you'd need to make a second call:

`bitcoin-cli gettransaction c5355fe45f785f14f15b3e41894e21083978e9e78ed23b7a3a00f0061ec735a5`

And then look at the output at the index `n: 1` to find the address in question.

> **Comments:**
> **username_0**: Thank you ! You can see this transaction here https://www.blockchain.com/btc/tx/2c33baf70886d48cc3259ca1dc5d3dde974394f476d5faa2673cb6e35721fd83     . .  The problem is that I am unable to see the "from address" in my output. I can make a second call to the txid in VIN, but I am trying to avoid that. The output is the receiver address. It has the other 2 addresses. 1 address is the actual receiver and the second address should be where it returns the remaining balance  
> **username_2**: error message: No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)  Why do you need a wallet to get info about transactions that do NOT include addresses you own?  If you have a wallet, then the error message is `Invalid or non-wallet transaction id`. So this answer is expected to wor for your transactions only.  
> **username_1**: @username_2 if you have `txindex=1` set then you can query any transaction, otherwise it would indeed work for your wallet's transactions only.  
> **username_2**: I do have `txindex=1 ` and all 800k+ blocks are on my disk. Maybe, something else?  
> **username_1**: @username_2 it would be best to open a new question, rather than discuss this in the comments of a somewhat unrelated question.  

---

