Frequently in popular descriptions of Bitcoin and in the user interfaces of wallet software, a distinction is made between “confirmed” and “unconfirmed” transactions. What is the difference?
At a high level, a transaction is only confirmed when it is permanently included in the Bitcoin blockchain. The blockchain is a ledger of all transactions in the history of Bitcoin. It is append-only, meaning new data can be added to the end of the ledger, but data can never be removed once included. This ledger is necessary to prevent double-spending, which is a key technical challenge in designing any cryptocurrency.
How Bitcoins are Transferred
Recall that if Alice “owns” some quantity of bitcoins, this really means she knows one or more cryptographic keys which have been designated as the controller of those coins in a transaction on the ledger which transferred the coins to Alice. In order to transfer the coins to another entity, Alice will use these keys to produce a digital signature on the statement “I would like to redeem (spend) this transaction and send the value to X, Y, Z…” where X, Y, and Z will be new cryptographic addresses representing keys known by other individuals (or perhaps Alice herself).
Now, suppose Alice signs a statement on her own computer saying she wants to transfer some coins to Bob but never sends the statement to Bob. In this case, clearly the coins have not been transferred. This is roughly like a tree falling in the forest with nobody around to hear it. However, sending the signed statement only to Bob is not enough, because Alice could have signed a conflicting transaction saying she wants to transfer the coins to Carol which she only sends to Carol. If Bob and Carol both accepted these statements as indicating that they have received the coins from Alice, then Alice will have effectively spent her coins twice!
This is where the idea of a global ledger comes in. If Alice wants to transfer her coins to Bob, she must publish her statement authorizing the transfer to the blockchain. The miners who maintain the blockchain will only include this transaction if Alice has not yet transferred the coins to anybody else, so once Bob sees the transaction appear in the blockchain he can be confident that he is the new owner. Even if Alice later tries to produce a statement saying she transfered the coins to Carol, it will never be accepted into the blockchain because the transaction transferring to Bob was published first.
So it seems simple: a transaction is “unconfirmed” once it has been produced and cryptographically signed and “confirmed” once it has been successfully included in the blockchain. Unfortunately, the blockchain does not offer strong consistency, meaning that any data included in the blockchain is guaranteed to be included forever. For technical reasons, the blockchain offers a weaker property called eventual consistency, meaning that eventually all parties will agree on the blockchain up to a certain ever-increasing prefix.
Put another way, the blockchain is a series of n blocks (currently almost 400,000), and at any given time the most recent several blocks are not guaranteed to be permanently included. It is possible for the blockchain to fork by having multiple potential (often inconsistent) blocks which claim to be the last block in the chain. Eventually one of these blocks will win and be permanently included, but it won’t always be immediately clear which block this is. When an apparently valid block is replaced by a competing block, this is called a blockchain reorganization and the replaced block is called anorphan block.
Given this we might be tempted to say a transaction is “confirmed” once it has been included in a block which is not the very last block in the blockchain. However, it is possible (although rare) for the last n blocks to be orphaned in a reorganization. This is exponentially less likely to occur the larger n gets. It typically happens multiple times a day, for example, that a single block is orphaned, but has happened only a few dozen times in history for n between 2 and 4, and exactly once for ngreater than 4 (a 24-block reorganization in March 2013 due to a technical glitch).
Barring technical glitches, formal modeling of Bitcoin suggests that large reorganizations are exponentially unlikely, but possible. Therefore we can never say with certainty that a transaction is “confirmed” because it is always possible that a transaction will apparently be included in the blockchain but be replaced by a large reorganization.
In practice, the community has adopted 6 blocks as a standard confirmation period. That is, once a transaction is included in a block in the blockchain which is followed up by at least 6 additional blocks, the transaction is called “confirmed.” While this was chosen somewhat arbitrarily, it is a reasonably safe value in practice as the only time this would have left users vulnerable to double-spending was the atypical March 2013 fork.
For very large transactions, coin owners might want to wait for a larger number of “block confirmations” and most wallet software now says more precisely that a transaction is “confirmed by n blocks” to enable users to decide for themselves if more confirmation is needed.
For relatively small transactions (like buying coffee), users might be fine with a shorter confirmation period such as one or even zero blocks. Even with only 1 confirmation (accepting a transaction once it is included in the most recent block in the chain) the risk of losing it to a reorganization is low (1-2%) and even then it will probably be re-included after the reorganization occurs.
How Long Does 6 Blocks Take?
Assuming Alice is fine with the community standard of 6 blocks, how long will she have to wait? “One hour” is the common answer but this is not quite the whole story. Because blocks are found by a random process, there is no telling precisely how long it will take for 6 blocks to be found. On average, it takes about 10 minutes to find each block. The average block time can actually be slightly shorter or longer depending on if the total hash power of the Bitcoin network is growing or shrinking. Ignoring this detail though, this is why 6 confirmations take about 1 hour on average. However, the block-creation (or mining) process is random and each block may take much longer or shorter.
At a high level, a transaction is confirmed when it is permanently included in the Bitcoin blockchain. The important takeaway though is that there is no absolute notion of “permanently included” and the community simply uses a reasonably safe policy of considering transactions confirmed when they are “included with very high probability.” The time it takes for this to happen is quite variable-sometimes confirmation may be tens of minutes and sometimes it may take over two hours, but on average it will take about an hour.
Dr. Joseph Bonneau is a researcher at Stanford University and a technology fellow at the Electronic Frontier Foundation. He has taught several university courses on cryptocurrency technology and is currently writing a textbook on the subject.