0

I’m able to get the value for vout but my node is not returning the value for vin, how do I get the value for vin?

3

Transaction inputs (vin's) are simply unspent transaction outputs of a previous transaction. Here's an example to help clarify:

"vin": [
    {
      "txid": "6adf304f0a3e2afc92d864086202551041dfe0543f3116cc6f5c3b29e795fcaa",
      "vout": 1,
      "scriptSig": {
        "asm": "3044022079aca1fc033403856de39f03c856bf54b79efdaa210237a858d10675635e7b9e02206163547e0df9322fc337ab807f2874fbe1baec303bd874b3eb19c43a56b955ed[ALL] 0424140e929701fe8ad2b00e2f0995fa37357c3e0f67fa4061d387fa88f3b33f3834fec71063060de578c191cc7ab52fb5a095b72a6b692e5740fe2739ec1fcd9f",
        "hex": "473044022079aca1fc033403856de39f03c856bf54b79efdaa210237a858d10675635e7b9e02206163547e0df9322fc337ab807f2874fbe1baec303bd874b3eb19c43a56b955ed01410424140e929701fe8ad2b00e2f0995fa37357c3e0f67fa4061d387fa88f3b33f3834fec71063060de578c191cc7ab52fb5a095b72a6b692e5740fe2739ec1fcd9f"
      },
      "sequence": 4294967295
    },
    {
      "txid": "0047a70c729621f3b27897edc7a7a89c55d094b0241a91dd7a7a0fcd5351cbdd",
      "vout": 1,
      "scriptSig": {
        "asm": "30450220776842cd9d76924f0648ff434b64fef8739952684c184b4ce959ebfb2d9c9b3d022100fc101c92309a693a9fcf67c41efbb6c55483edc41d6fd66e3b3bbec7cc95fe88[ALL] 0424140e929701fe8ad2b00e2f0995fa37357c3e0f67fa4061d387fa88f3b33f3834fec71063060de578c191cc7ab52fb5a095b72a6b692e5740fe2739ec1fcd9f",
        "hex": "4830450220776842cd9d76924f0648ff434b64fef8739952684c184b4ce959ebfb2d9c9b3d022100fc101c92309a693a9fcf67c41efbb6c55483edc41d6fd66e3b3bbec7cc95fe8801410424140e929701fe8ad2b00e2f0995fa37357c3e0f67fa4061d387fa88f3b33f3834fec71063060de578c191cc7ab52fb5a095b72a6b692e5740fe2739ec1fcd9f"
      },
      "sequence": 4294967295
    }
  ],

So to get the value for the first vin, you'll need to make another getrawtransaction call with txid: 6adf304f0a3e2afc92d864086202551041dfe0543f3116cc6f5c3b29e795fcaa

Then look for the 2nd vout output (since vout is 1, which means index 1). So the value will be 0.02039242:

  "vout": [
    {
      "value": 0.02000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 27470c0fb0c4a68221f80bf01bf0e267a0a48d68 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a91427470c0fb0c4a68221f80bf01bf0e267a0a48d6888ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "14agTvSiZV33GSYroQCP8p7fyYjUVBE7BU"
        ]
      }
    },
    {
      "value": 0.02039242,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 65be988f0a457cf68203271536428698776f2c51 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a91465be988f0a457cf68203271536428698776f2c5188ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1AGyaDKdHWo8TcGADUCWd8JYXMQrky8Uko"
        ]
      }
    }
  ],

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.