How can I get the confirmations of a transaction using bitcoind? I installed bitcoind on my linux server. So far, it has downloaded blocks 0-386561 according to bitcoin-cli getinfo.

I went to a random block within that range, and picked up this transaction:

TXID: a3d7b336b5e1024de75c21612bc8af7f4b30e05ccb863a438463fda4034d34db

I want to check how many confirmations this transaction has using my bitcoind through a CLI command.

So I typed bitcoin-cli gettransaction a3d7b336b5e1024de75c21612bc8af7f4b30e05ccb863a438463fda4034d34db.

It gave me this:


Can someone please explain what is wrong??
Like it says, gettransaction can only return info on transactions which are part of your wallet, i.e. those which send coins to or from one of your own addresses.

Normally Bitcoin Core doesn't keep track of any data on non-wallet transactions, but this can be turned on with the -txindex option.  (Building the transaction index for the first time will also require you to reindex the entire blockchain with -reindex, which will take several hours to days and a fair amount of extra disk space.)  With this turned on, you can use getrawtransaction with any past transaction, wallet or not; if you want human-readable output, including number of confirmations, add true after the txid.