2

I'm trying to get transactions infos out of the bitcoin core wallet with the console. For that I picked a random transaction of a block from today and tried to access it with

gettransaction 8c0430d0139603db9983daf539604c612b3f7e8d5244aefc3cd3181ece08dd1f

Instead of a json-output with the decoded transaction I get

Invalid or non-wallet transaction id (code -5)

Shouldn't I be able to retrieve every transaction in the blockchain with this command?

How can I read/access the transactions included in mined blocks? I already did this on some altcoins with PoS and there is was possible for every transaction. Now with bitcoin it seems that only wallet transactions are available? Why is that and can I get around that to access / read the transactions on my own?

The same problem appears to be with the getrawtransaction command, so I can even decode a transaction on my own.

I run a bitcoin core 0.14.2 and my blockchain is up-to-date.

1 Answer 1

1

To retrieve arbitrary transactions in the Bitcoin Core console, you need to use the txindex=1 option in your configuration file.

Note that setting that option will trigger a full rescan of the blockchain that might (depending on your setup) take several hours to complete.

5
  • thanks. I'm rescanning now and try again after that. I also observed, that some transactions did return tx-data anyway without txindex set to 1. Can you explain how that could be possible? Sep 13, 2017 at 16:25
  • Bitcoin Core will return transaction information for transactions you sent (and maybe received, not sure about this one).
    – alcio
    Sep 13, 2017 at 16:29
  • I set txindex=1 and did a full rescan (took long time). after that I restartet my client and tried again. Still not able to access transactions. Same error again. Sep 15, 2017 at 20:18
  • 1
    getrawtransaction seems to work with all transactions I checked, but gettransaction still fails. Sep 15, 2017 at 20:24
  • You must run Bitcoin Core with -reindex option and wait till whole reindex. gettransaction works only for wallet txes, getrawtransaction works for all txes.
    – pbies
    Aug 28, 2023 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.