<p>If you want to get the <code>gettransaction</code> command running, you would need to enable the txindex via <code>bitcoind -reindex -txindex</code>. Note this takes a few hours.</p>

<p>Alternatively, you can do the following:</p>

<ol>
<li>run <code>bitcoin-cli getblockhash &lt;block number&gt;</code></li>
<li>run <code>bitcoin-cli getblock &lt;result from 1&gt;</code></li>
</ol>

<p>This will give you the block time and all the transactions within the block in a nice JSON format. Iterate through all the txid's via:</p>

<p><code>bitcoin-cli getrawtransaction</code></p>

<p>Unfortunately, you'll have to look up all the inputs and see how much is in them in order to calculate the transaction fee using this method.</p>

CC BY-SA 3.0
2015-12-09T17:59:26.280Z
Thanks, I was unaware of the -txindex flag, I'm now letting my client reindex. The second method you describe is the one I've tried before. Unfortunately, tx.vin does not list the transaction volume with this method.
mxschumacher
CC BY-SA 3.0
2015-12-09T18:01:18.880Z
Yea, looking up the original tx's can be a huge pain. It's not too hard if you write a script to do it for you, though.
Jimmy Song
CC BY-SA 3.0
2015-12-10T17:16:16.010Z
So, now I did rerun bitcoin-core with the flags you've mentioned but the problem persists, e.g. same error message. Do you have any more tips?
mxschumacher
CC BY-SA 3.0
2015-12-09T17:51:26.000Z
2015-12-09T17:58:22.723Z
2015-12-09T17:58:22.723Z
Jimmy Song
<p>For a research project I need to analyse all transactions that happened in 2015. All I care about are volumes transacted, fees paid and a timestamp per transaction or corresponding block.</p>

<p>Getting this data via APIs over the net creates lots of overhead and lets me run into rate limits (I cannot just run 50 million+ queries against blockchain.info or the coinbase-API).</p>

<p>So I would like to get the data out of my local instance of bitcoin-core.</p>

<p>Unfortunately running gettransaction  fails both programatically and via the commandline, despite the fact that I'm running bitcoind with the -reindex flag enabled:</p>

<pre><code>{ [Error: Invalid or non-wallet transaction id] code: -5 }
</code></pre>

<p>I resorted to using getrawtransaction  1 which, unfortunately, only returns the transacted volumes per output. I take the txid of inputs and query the local instance again. A tedious-error prone process, I would like to know whether there is an easier way.</p>

<p>So, can somebody please help me with getting gettransaction working?</p>

<transactions><bitcoin-core><transaction-fees><gettransaction>
Get transaction fees per transaction via gettransaction
mxschumacher
# Get transaction fees per transaction via gettransaction

(Asked by: username_0 on 2015-12-09)

For a research project I need to analyse all transactions that happened in 2015. All I care about are volumes transacted, fees paid and a timestamp per transaction or corresponding block.
Getting this data via APIs over the net creates lots of overhead and lets me run into rate limits (I cannot just run 50 million+ queries against blockchain.info or the coinbase-API).
So I would like to get the data out of my local instance of bitcoin-core.
Unfortunately running gettransaction  fails both programatically and via the commandline, despite the fact that I'm running bitcoind with the -reindex flag enabled:
{ [Error: Invalid or non-wallet transaction id] code: -5 }

I resorted to using getrawtransaction  1 which, unfortunately, only returns the transacted volumes per output. I take the txid of inputs and query the local instance again. A tedious-error prone process, I would like to know whether there is an easier way.
So, can somebody please help me with getting gettransaction working?

**Tags:** transactions, bitcoin-core, transaction-fees, gettransaction


---

## 1 answers

### Answer by username_1 on 2015-12-09. Score: 2

If you want to get the `gettransaction` command running, you would need to enable the txindex via `bitcoind -reindex -txindex`. Note this takes a few hours.

Alternatively, you can do the following:

1. run `bitcoin-cli getblockhash`
2. run `bitcoin-cli getblock`

This will give you the block time and all the transactions within the block in a nice JSON format. Iterate through all the txid's via:

`bitcoin-cli getrawtransaction`

Unfortunately, you'll have to look up all the inputs and see how much is in them in order to calculate the transaction fee using this method.

> **Comments:**
> **username_0**: Thanks, I was unaware of the -txindex flag, I'm now letting my client reindex. The second method you describe is the one I've tried before. Unfortunately, tx.vin does not list the transaction volume with this method.  
> **username_1**: Yea, looking up the original tx's can be a huge pain. It's not too hard if you write a script to do it for you, though.  
> **username_0**: So, now I did rerun bitcoin-core with the flags you've mentioned but the problem persists, e.g. same error message. Do you have any more tips?  

---

