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

# -*- coding: utf-8 -*-
import requests,json
payload = {"jsonrpc":1,"id":"curltext"}
 txid= "10ff6ff5bdc73d7bb6d711c6896618a05479d061e67f576a0950328c1389035f"
addresses = []

response = requests.post(url,json.dumps(payload))
response =response.json()
response= response["result"]["vin"]

for data in response:
    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"]

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?

1 Answer 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.

  • 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
    – cryptoKTM
    May 3, 2018 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.