Author

Topic: Transaction Inputs (Read 248 times)

legendary
Activity: 1463
Merit: 1886
June 04, 2019, 12:14:47 PM
#5
I know it, but output change index every time. I saw transaction where output which i need was in 1. In this example output in 0. I must know every time where my output locate

Yup. That's what "vout" means. I knew it was the 0th because in the example I gave it said 0. But as you've realized, it's often different.
newbie
Activity: 13
Merit: 1
June 04, 2019, 04:20:22 AM
#4
I know it, but output change index every time. I saw transaction where output which i need was in 1. In this example output in 0. I must know every time where my output locate
legendary
Activity: 1463
Merit: 1886
June 04, 2019, 01:07:27 AM
#3
It's pretty annoying, but a transaction doesn't encode the input amounts or fee. So you have to derive it yourself.

If you look at your first input of your transaction was:

Code:
   {
      "txid": "a13300eb2da6fc3d2d8f0a19cc8fa26fcb626544dfe298657384baf6a3bafffa",
      "vout": 0,
      ...
   }

So we need to fetch that transaction and look at the 0th  (first)   output which says the amount ( in this case: 0.01398886 tBTC). When you do that for all inputs, you can calculate the amount of bitcoin sourced. Subtract how much the transaction sent, and the left over is the fee.

---

BTW if you're only looking at unconfirmed transactions, a lot of the rpc methods in core will actually tell you the fees of it.
legendary
Activity: 4522
Merit: 3426
June 03, 2019, 03:07:20 PM
#2
Code:
...
  "vin": [
    {
      "txid": "a13300eb2da6fc3d2d8f0a19cc8fa26fcb626544dfe298657384baf6a3bafffa",
      "vout": 0,
      ...
    },
    {
      "txid": "5102bb4807593b24917c0782f9d50d5f3eb11715357bfcb91bcde2d2f65ad23d",
      "vout": 0,
      ...
    }
  ],
    ...

The inputs of the transaction are outputs 0 and 0 of transactions a13300eb2da6fc3d2d8f0a19cc8fa26fcb626544dfe298657384baf6a3bafffa and 5102bb4807593b24917c0782f9d50d5f3eb11715357bfcb91bcde2d2f65ad23d. Is that what you want to know?
newbie
Activity: 13
Merit: 1
June 03, 2019, 10:09:57 AM
#1
Hi, guys!

How i can get more information about input? I need to know input value because i want to calculate fee.
Maybe you know how i can calculate fee easier because i want subtract sum of inputs with sum of outputs!Thx!
Code:
{
  "txid": "d765459127e6ccdb8cd040e78ef682ede7d983675f764fa77fb59137b35909eb",
  "hash": "1a80b7177a933b9e33c8fc981973b4f943325a196c7a59e279a620b40ea2ca04",
  "version": 2,
  "size": 372,
  "vsize": 210,
  "locktime": 1518869,
  "vin": [
    {
      "txid": "a13300eb2da6fc3d2d8f0a19cc8fa26fcb626544dfe298657384baf6a3bafffa",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "3044022057464a3514fde7506a951234f125ef8f8712a7343c31a01ff85f58588be53f4902206714a6fb43b0
e2aea6b84daeffc2d81de66d6757897c0ae2841e20d34fc27701",
        "02ca1eab6d2bbe2cacc8586127938667b9e57dc7db6561becd79935da5d708c123"
      ],
      "sequence": 4294967294
    },
    {
      "txid": "5102bb4807593b24917c0782f9d50d5f3eb11715357bfcb91bcde2d2f65ad23d",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402207f184cbb1ad21a22c0b60eb4e778006b378569b274290c840e8c2a944da7b06c02203a1d1a5eff4c
3ceb6d3f47f10716adca0aa157561b8eaf642ba6f1a497038301",
        "021d6943965a2b9ca7a8696a99f87cd6a5bc717ad66bc1101f5213c463a1bbeee3"
      ],
      "sequence": 4294967294
    }
  ],
  "vout": [
    {
      "value": 0.01000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_HASH160 5fb08d7e43c1293dbd444da17c321e06ac2718a4 OP_EQUAL",
        "hex": "a9145fb08d7e43c1293dbd444da17c321e06ac2718a487",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2N1yBgc3cttCJNTvm8Dxi87SB6NXgo2Cr5p"
        ]
      }
    },
    {
      "value": 0.01797587,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_HASH160 7be878c8010286a567731ffa8ec083ccac31c334 OP_EQUAL",
        "hex": "a9147be878c8010286a567731ffa8ec083ccac31c33487",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2N4YPbJXjNkMntrLQx8HhDTKFd1YTFxPq1Q"
        ]
      }
    }
  ]
}
Jump to: