<p><strong>Fees are the difference between the total inputs and the total outputs.</strong> </p>

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

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

<blockquote>
  <p>bitcoin-cli getrawtransaction
  10ff046cb00483c4b4222fe3d1798b98d5a17af55ff7fc0a6e1e2398b86c13bd 1</p>
</blockquote>

<p>In this example there is only 1 output: </p>

<pre><code>  "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"
        ]
      }
    }   ], ...
</code></pre>

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

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

<p>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:</p>

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

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

CC BY-SA 4.0
2018-07-31T20:56:33.573Z
2018-07-31T20:56:33.573Z
sizzlecookie
<p>Here is the transaction id as an example, please help me calculate using bitcoind: 10ff046cb00483c4b4222fe3d1798b98d5a17af55ff7fc0a6e1e2398b86c13bd</p>

CC BY-SA 4.0
2018-08-01T00:11:36.867Z
Possible duplicate of [Calculation of transaction fee for transaction](https://bitcoin.stackexchange.com/questions/60490/calculation-of-transaction-fee-for-transaction)
Fuzzybear
CC BY-SA 4.0
2018-08-01T16:30:50.853Z
My question specifically pertains to using bitcoind, the other question is a little more broad.
TictacTwo
<bitcoind>
How do you calculate fees with bitcoind?
TictacTwo
# How do you calculate fees with bitcoind?

(Asked by: username_0 on 2018-07-31)

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

**Tags:** bitcoind

> **Comments:**
> **username_1**: Possible duplicate of [Calculation of transaction fee for transaction](https://bitcoin.stackexchange.com/questions/60490/calculation-of-transaction-fee-for-transaction)  
> **username_0**: My question specifically pertains to using bitcoind, the other question is a little more broad.  

---

## 1 answers

### Answer by username_2 on 2018-07-31. Score: 1 | Accepted answer

**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


---

