3

We are building a generic wrapper around Bitcoin-Qt. I wonder if there is way to get the information about the confirmation count of a transaction from a Bitcoin-QT having an empty wallet using the RPC command.

  • 1
    Can you clarify the question? Do you want to know confirmation count for addresses which you own the private key for or is that what you mean by "empty wallet"? Also, clarify scale of project (ie estimated number of addresses you're checking and how ften). More dtails the better! – Wizard Of Ozzie Oct 8 '14 at 13:58
3

You can use the RPC command "getrawtransaction" to receive a JSON response with information for that transaction including a "confirmations" field if that transaction has been included in a block (if there are 0 confirmations the confirmations field will not be there). You should note though that if you are looking for transactions that are not actually a part of your wallet (from or to an address you don't have the private keys for) bitcoin-qt by default won't keep track of these transactions and will have to be run with the "txindex=1" flag set to keep a full transaction index.

  • "txindex=1" flag set to keep a full transaction index.>>>> does this give us the confirmation count ? – Rıfat Erdem Sahin Oct 9 '14 at 8:42
  • Setting "txindex" to 1 tells the bitcoin node to keep track of all transactions, not just the ones relevant to your wallet. This way you can use "getrawtransaction" on any txid (Barring the genesis block coinbase transaction, as that is not technically a valid tx). You will also need to run with "reindex=1" if you already have the blockchain downloaded and need to refresh it to use this new indexing system. (All of these settings can also be set in your "Bitcoin.conf" configuration file as opposed to command line flags en.bitcoin.it/wiki/…) – CJ-Coinsetter Oct 9 '14 at 15:27
1

You will need to:

  1. Set txindex=1 in ~/.bitcoin/bitcoin.conf
  2. Restart bitcoind with -reindex option i.e.,

    bitcoind -reindex &

After this, use 'getrawtransaction' command and provide the additional argument '1' to get the response in JSON format, i.e.,

bitcoin-cli getrawtransaction your_tx_hash 1

Interestingly, first getting the raw transaction in hex (without the additional argument 1) and then using 'decoderawtransaction' does not give you the 'confirmations' field in the output.

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.