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.