<p>You can code it, 
Python 2.7 implementation for same is:</p>

<pre><code>#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ ="cryptoKTM"

import requests,json
url="http://username:password@server:PORT"
payload={}
payload = {"jsonrpc":1,"id":"curltext"}
txid= "10ff6ff5bdc73d7bb6d711c6896618a05479d061e67f576a0950328c1389035f"
addresses = []
payload["method"]="getrawtransaction"
payload["params"]=[txid,1]
response = requests.post(url,json.dumps(payload))
response =response.json()
response= response["result"]["vin"]
for data in response:
    raw_tx1=data["txid"]
    vout_int=data["vout"]
    payload["params"]=[raw_tx1,1]
    response_ = requests.post(url,json.dumps(payload))
    response_= response_.json()
    data_ =response_["result"]["vout"]
    for item in data_:
        if item["n"] == vout_int:
            json_data ={}
            json_data[item["scriptPubKey"]["addresses"][0]] = item["value"]
            addresses.append(json_data)

print addresses
</code></pre>

CC BY-SA 4.0
2018-05-04T06:36:47.053Z
2018-05-04T06:36:47.053Z
Parishilan Rayamajhi
<p>First, use the API to get the information on the <code>txid</code>.</p>

<pre><code>/api/tx/e3f0e88ce224d342a0189c1b9d2fd488d8bda2f303dbe1e1dbbaa5f51d9f4a53
</code></pre>

<p><a href="http://live.insight.is/api/tx/e3f0e88ce224d342a0189c1b9d2fd488d8bda2f303dbe1e1dbbaa5f51d9f4a53" rel="noreferrer">This result</a> will include all of the details you're looking for. Here are the parts that you're asking about. The <code>n</code> here corresponds to the <code>vout</code> number above, I believe, and the <code>value</code> and <code>addresses</code> values are the input amount and address.</p>

<pre><code>"value": "2405.38864196",
"n": 1,
"scriptPubKey": {
    ...
    "addresses": [
        "1NG1nT2ZuFw47f41mGjYpPp7J837yTQZhB"
    ]
},
...
</code></pre>

CC BY-SA 3.0
2017-12-11T15:53:29.957Z
So when I'm reading block 255 145 and I want to know from where is taken the input I have to rescan all the previous block looking for that TX ? :o (I'm parsing the blockchain mannualy)
sliders_alpha
CC BY-SA 3.0
2017-12-16T21:15:17.773Z
@sliders_alpha Yeah, potentially. If you want to be more efficient, as you scan the blockchain going forward, keep a list of transaction id's and which block they came in.
Tim S.
CC BY-SA 3.0
2014-05-23T18:23:58.767Z
2014-05-23T18:23:58.767Z
Tim S.
<p>I like to find the Input Address and Amount for a vin like this:</p>

<pre><code>"vin": [
    {
        "txid": "e3f0e88ce224d342a0189c1b9d2fd488d8bda2f303dbe1e1dbbaa5f51d9f4a53",
        "vout": 1,
        "scriptSig": {
            "asm": "3044022036c454ee41d67ee7c00fade55d57b573794916c1e1d9f301a038547daa5fcc0502202c99917b5590adf2ede1b8e3a6773369690a268c7b445664223ec8f92288e81e010272491cc9c405bfdc35f766bd849ddc58268088c202425cec224aa05cbf8547be"
        },
        "sequence": 4294967295,
        "n": 0,
        "unconfirmedInput": 1
    }
]
</code></pre>

<p>This is from txid: f4f2ddb44a8d155bc795e3e7497714fd6a1f035a6438b22403a7faa67012b9ec</p>

<p>Thanks</p>

<transactions><address><api>
How to get the Input Address from vin where only a txid is given (Insight-Api)
thepiwo
# How to get the Input Address from vin where only a txid is given (Insight-Api)

(Asked by: username_0 on 2014-05-23)

I like to find the Input Address and Amount for a vin like this:

```
"vin": [
    {
        "txid": "e3f0e88ce224d342a0189c1b9d2fd488d8bda2f303dbe1e1dbbaa5f51d9f4a53",
        "vout": 1,
        "scriptSig": {
            "asm": "3044022036c454ee41d67ee7c00fade55d57b573794916c1e1d9f301a038547daa5fcc0502202c99917b5590adf2ede1b8e3a6773369690a268c7b445664223ec8f92288e81e010272491cc9c405bfdc35f766bd849ddc58268088c202425cec224aa05cbf8547be"
        },
        "sequence": 4294967295,
        "n": 0,
        "unconfirmedInput": 1
    }
]

```

This is from txid: f4f2ddb44a8d155bc795e3e7497714fd6a1f035a6438b22403a7faa67012b9ec

Thanks

**Tags:** transactions, address, api


---

## 2 answers

### Answer by username_2 on 2014-05-23. Score: 5 | Accepted answer

First, use the API to get the information on the `txid`.

```
/api/tx/e3f0e88ce224d342a0189c1b9d2fd488d8bda2f303dbe1e1dbbaa5f51d9f4a53

```

[This result](http://live.insight.is/api/tx/e3f0e88ce224d342a0189c1b9d2fd488d8bda2f303dbe1e1dbbaa5f51d9f4a53) will include all of the details you're looking for. Here are the parts that you're asking about. The `n` here corresponds to the `vout` number above, I believe, and the `value` and `addresses` values are the input amount and address.

```
"value": "2405.38864196",
"n": 1,
"scriptPubKey": {
    ...
    "addresses": [
        "1NG1nT2ZuFw47f41mGjYpPp7J837yTQZhB"
    ]
},
...

```

> **Comments:**
> **username_3**: So when I'm reading block 255 145 and I want to know from where is taken the input I have to rescan all the previous block looking for that TX ? :o (I'm parsing the blockchain mannualy)  
> **username_2**: @username_3 Yeah, potentially. If you want to be more efficient, as you scan the blockchain going forward, keep a list of transaction id's and which block they came in.  

---

### Answer by username_1 on 2018-05-04. Score: 1

You can code it,
Python 2.7 implementation for same is:

```
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ ="cryptoKTM"

import requests,json
url="http://username:password@server:PORT"
payload={}
payload = {"jsonrpc":1,"id":"curltext"}
txid= "10ff6ff5bdc73d7bb6d711c6896618a05479d061e67f576a0950328c1389035f"
addresses = []
payload["method"]="getrawtransaction"
payload["params"]=[txid,1]
response = requests.post(url,json.dumps(payload))
response =response.json()
response= response["result"]["vin"]
for data in response:
    raw_tx1=data["txid"]
    vout_int=data["vout"]
    payload["params"]=[raw_tx1,1]
    response_ = requests.post(url,json.dumps(payload))
    response_= response_.json()
    data_ =response_["result"]["vout"]
    for item in data_:
        if item["n"] == vout_int:
            json_data ={}
            json_data[item["scriptPubKey"]["addresses"][0]] = item["value"]
            addresses.append(json_data)

print addresses

```


---

