<p>That error means that either <code>response</code> or <code>response['result']</code> is <code>None</code> which means that <code>getrawtransaction</code> is probably unable to find the transaction id that you are providing.</p>

<p>Before you try to read data from the response, make sure it isn't <code>None</code> and actually has a result.</p>

CC BY-SA 4.0
2018-05-03T08:06:10.280Z
i guess issue was because i didnt mentionled txindex flag in my .conf file. Now when i put txindex=1 it seems to be working fine
Parishilan Rayamajhi
CC BY-SA 4.0
2018-05-03T03:12:17.040Z
2018-05-03T03:12:17.040Z
Ava Chow
<p>I have written following script to get Vin address from Vin txids.</p>

<pre><code>#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests,json
url="http://asd:asdf@localhost:2332"
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>

<p>for some txids i get proper o/p for example:</p>

<pre><code>[{u'MKHWXiX9Xm37jdCM8EzWMWNRJPhuwUxWiN': 50.0},{u'MVTpa2h3DGFWxkcmEkYLv4cYGggVprjjDZ': 300.0}]
</code></pre>

<p>but for other its says</p>

<pre><code>    response= response["result"]["vin"]
TypeError: 'NoneType' object has no attribute '__getitem__'
</code></pre>

<p>Why is it behaving like this? Isnt it supposed to have uniform output irrespective of txids? If my approach is wrong then how was i getting correct for some tx ids again?</p>

<transactions><bitcoin-core><bitcoind><nonce><transaction-id>
Get input address using VIN txid?
Parishilan Rayamajhi
# Get input address using VIN txid?

(Asked by: username_0 on 2018-05-03)

I have written following script to get Vin address from Vin txids.

```
#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests,json
url="http://asd:asdf@localhost:2332"
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

```

for some txids i get proper o/p for example:

```
[{u'MKHWXiX9Xm37jdCM8EzWMWNRJPhuwUxWiN': 50.0},{u'MVTpa2h3DGFWxkcmEkYLv4cYGggVprjjDZ': 300.0}]

```

but for other its says

```
    response= response["result"]["vin"]
TypeError: 'NoneType' object has no attribute '__getitem__'

```

Why is it behaving like this? Isnt it supposed to have uniform output irrespective of txids? If my approach is wrong then how was i getting correct for some tx ids again?

**Tags:** transactions, bitcoin-core, bitcoind, nonce, transaction-id


---

## 1 answers

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

That error means that either `response` or `response['result']` is `None` which means that `getrawtransaction` is probably unable to find the transaction id that you are providing.

Before you try to read data from the response, make sure it isn't `None` and actually has a result.

> **Comments:**
> **username_0**: i guess issue was because i didnt mentionled txindex flag in my .conf file. Now when i put txindex=1 it seems to be working fine  

---

