This question already has an answer here:

Sorry for this naive question, but honestly it is going to be a great help for me. Say I am tracking a specific bitcoin transaction('TX_1') form bitcoin core. A confirmed block had the transaction information after I decoded the block, and I updated my database as : {transaction: 'TX_1', 'confirmation': 1} now how do I increment the number of confirmation, assuming I am still listening to the network through ZMQ. Should I expect the same transaction ('TX_1') to be present in upcoming blocks?

marked as duplicate by Pieter Wuille, Raghav Sood, MCCCS, Gopoi, Andrew Chow May 21 '18 at 18:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


A tx will only be included in a single block in any given blockchain.

Confirmations is simply a count of how many new blocks extend the chain.

If your tx is in block n, it has 1 confirmation. When block n+1 is mined, you need to check that the prevblockhash is the hash of block n. If it is, you now have 2 confirmations, since the chain has been mined. When block n+2 is mined, you check the prevblockhash against the hash of block n+1. If this is valid, you now have 3 confirmations, since block n+1 builds upon the block with your tx, and block n+2 builds upon block n+1. You can keep checking this for as many blocks as you feel necessary to guarantee that your tx will not be dropped. Most wallets/exchanges check until a tx has 6 confirmations.

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