I am running bitcoin-d (probably downloading the prev blocks) in a shell. In another shell i am trying to get the information of a transaction (0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2) with bitcoin-cli. I can see that tx on blockchain.info but when i tried it with gettransaction and getrawtransaction it didn't work out. Does anyone know why is that? screenshot below. enter image description here

  • Try to call the command getrawtransaction this is documentation reference if not work, can you public a minimal example for trying the same command? Sep 23 '19 at 16:25
  • It says like that: Efe-MacBook-Pro:bitcoin efecini$ bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2 error code: -5 error message: No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.
    – Efe Cini
    Sep 23 '19 at 16:51
  • with the command getrawtransaction the your code worked follow pieter's instructions Sep 23 '19 at 16:57
  • I restarted the os and typed bitcoind '-txindex=1' And also add a newline 'txindex=1' in bitcoin.conf.(Also i cant find bitcoin.conf file after i changed it :( ) But stil i get : error code: -5 error message: No such mempool or blockchain transaction. Use gettransaction for wallet transactions.
    – Efe Cini
    Sep 23 '19 at 22:10
  • if you run the bitcoind with the --daemon it appare ok but with the -txindex=1 the bitcoin core the blockchain is rescanned so you attend the time for complete the process, it should be the problem. for the bitcoin.conf disappeared, only you can know what dark has happened :) Sep 23 '19 at 22:21

gettransaction is a wallet RPC. It only works for transactions your wallet knows about. Presumably this is not the case for a transaction from 2013.

getrawtransaction is a node RPC. It works for all transactions, but needs help to find them. One possibility is to enable the transaction index (put txindex=1 in bitcoin.conf, or -txindex on the bitcoind command line). Another option is specifying which block the transaction is in.

  • There are 2 files : bitcoin.conf and bitcoind.conf. In bitcoin.conf: it is all comments. Is that the right file that i should edit? In some part it writes: # Enable pruning to reduce storage requirements by deleting old blocks. # This mode is incompatible with -txindex and -rescan. # 0 = default (no pruning). # 1 = allows manual pruning via RPC. Should i add the line there?
    – Efe Cini
    Sep 23 '19 at 16:57

For the answer to this comment

Can you give one example of how to do this in cmd as Pieter said : -txindex on the bitcoind command line

I do an example for my configuration bitcoin core, I using the -txindex

the command for run bitcoin

bitcoind -txindex

The essential bitcoin.conf configurations

## bitcoin.conf configuration file. Lines beginning with # are comments.

the process bitcoind with the -txindex is longer because bitcoind indexes all block inside the DB, an example, I used an external HDD and in my cases, the process worked for one day

also when the bitcoind has finished you can run your command, so

bitcoin-cli  getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

You will have this result


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.