I have a question, How can I get the number of transaction confirmation by using bitcoind?

for example: https://live.blockcypher.com/btc-testnet/tx/9fd745521000d1aadb1f4857e44817c3342d02585af93c83d19dc3f3f4425594/

you can see the number of CONFIRMATIONS on that page

thank you in advance!


Use bitcoin-cli getrawtransaction "txID" 1

The output will include a "confirmations" field, telling you how many confirmations the transaction currently has.

Note that to get this information for transactions not related to your wallet, you will need to set txindex=1 when syncing your your node, or provide bitcoin-cli with the blockhash of the block the transaction was included in. Here is some more info about this, copied from the output of bitcoin-cli help getrawtransaction, running v0.17.0.1:

NOTE: By default this function only works for mempool transactions. If the -txindex option is
enabled, it also works for blockchain transactions. If the block which contains the transaction
is known, its hash can be provided even for nodes without -txindex. Note that if a blockhash is
provided, only that block will be searched and if the transaction is in the mempool or other
blocks, or if this node does not have the given block available, the transaction will not be found. 
  • I tried decoderawtransaction 02000000000101fca5041df91d39bca183f0d477e44fef535f60fd8ba6b829aee8781407abda0800000000171600140976d58d4db681de489b95b549bcfa1333190ee9feffffff02661c43000000000017a9149a3aa2465229a8a9fc1614f8c83eb7107c94fa4887d8940300000000001976a9142745fd0fcf649cf333009589020bc2b40de12b3c88ac024730440220180d48c51fc0ad33d77a078d2bf3ee829bdf52e483ecac56c4c59e983cf30c8e02206f5712841bd6a97cce238b736aabee60c3f5b9365c2c38c11a0604e3c2c7de2201210366a92cde1eed31af6348ff72d6dab13b82ffec92fc7d8546c05530175e616c495e261700 but I can't see confirmations in there
    – bbnn
    May 19 '19 at 7:36
  • @bbnn that is because decoderawtransaction doesn't give you the number of confirmations, hence why I suggested the use of getrawtransaction, which does.
    – chytrik
    May 19 '19 at 7:41
  • the example that you gave produced error: parameter 1 must be of length 64 (not 4, for 'txID')
    – bbnn
    May 19 '19 at 8:11
  • oh I think I got it now I should replace the txID with the txID.. sorry
    – bbnn
    May 19 '19 at 8:12
  • @bbnn no problem, happy to help
    – chytrik
    May 20 '19 at 2:50

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.