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



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


This result 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": [
| improve this answer | |
  • 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 Dec 11 '17 at 15:53
  • @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. Dec 16 '17 at 21:15

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

# -*- coding: utf-8 -*-
__author__ ="cryptoKTM"

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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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