0

Here is the transaction id as an example, please help me calculate using bitcoind: 10ff046cb00483c4b4222fe3d1798b98d5a17af55ff7fc0a6e1e2398b86c13bd

2
1

Fees are the difference between the total inputs and the total outputs.

To retrieve the total out: Let’s make a getrawtransaction request with this transaction id, and add all the "vout" values together to get the total.

The request will look like this (use "1" at the end to return JSON):

bitcoin-cli getrawtransaction 10ff046cb00483c4b4222fe3d1798b98d5a17af55ff7fc0a6e1e2398b86c13bd 1

In this example there is only 1 output:

  "vout": [
    {
      "value": 3.60555045,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 ccc497f13cf4c598201e4b12353649be44172b01 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914ccc497f13cf4c598201e4b12353649be44172b0188ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1KfiMh5SDTYBGrDDHfSegrHkkWZQ2mSXtP"
        ]
      }
    }   ], ...

To retrieve the total input: We need make an additional request for each input to get the input values. So in this example there is one input:

  "vin": [
    {
      "txid": "b13b4765e46228f3239858c9f18e766b72bed24a56c52b9692e7f021c376e7ce",
      "vout": 1,
      "scriptSig": {
        "asm": "3044022044ca9b69f8c14eccd400be62a5320c8938aee176033c91f4cb17f57b14a20de402206e520a6398b01467772395557415bde2b7879e0e554eb6306718aa81fae5247d[ALL] 0373b9e8c6bd75e3029c00d629baff141895a4444d55894d48f0426842608d8e4d",
        "hex": "473044022044ca9b69f8c14eccd400be62a5320c8938aee176033c91f4cb17f57b14a20de402206e520a6398b01467772395557415bde2b7879e0e554eb6306718aa81fae5247d01210373b9e8c6bd75e3029c00d629baff141895a4444d55894d48f0426842608d8e4d"
      },
      "sequence": 4294967295
    }
  ],
...

We are interested in the "txid" and "vout". We need to make an additional getrawtransaction request for this id, and look at the value of the 2nd ouput (since vout is 1). That output is here:

{
  "value": 3.61007045,
  "n": 1,
  "scriptPubKey": {
    "asm": "OP_DUP OP_HASH160 02952d768c840f30a49e20af5bd4219210a14d24 OP_EQUALVERIFY OP_CHECKSIG",
    "hex": "76a91402952d768c840f30a49e20af5bd4219210a14d2488ac",
    "reqSigs": 1,
    "type": "pubkeyhash",
    "addresses": [
      "1Ef4RcUBZfrFyoVxZeU7tH5dRd9SXcJHN"
    ]
  }
}

Now we can subtract the total inputs from the total outputs to get the fees: 3.61007045 - 3.60555045 = 0.00452 in fees

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.