What is Double Spending & How Does Bitcoin handle it?

#bitcoin #blockchain #double-spending #51%attack #finneyattack

Akash Sahoo Feb 07 2021 · 3 min read
Share this
User trying to transfer same BTC to other users and getting rejected instead.

Double spending means spending the same money twice. Owning bitcoin means, you own bits of code that consists of bitcoins.

Let’s consider this example…

You go to Domino’s and order a cheese burst pizza worth $25.99. You pay in cash. Now that $25.99 in cash is in the cash vault of Domino’s. By all means, you simply can’t spend the same $25.99 somewhere else to make another purchase.

Unless you steal it :D…!!!

As you paid with your $25.99 bill, the service provider at Domino’s instantly confirmed that you have paid, and you received your delicious pizza in exchange for the money.


In our Domino’s example, you paid in cash, so the payment was confirmed and verified instantly by another human. But with digital currency like BTC, if this verification mechanism is missing, it can lead to double spending.

Anyone can just copy that digital money and pay somewhere else.

And here is where the unique invention lies…

Bitcoin, although being a digital currency, solves the problem of being copied and getting spent twice.

How Bitcoin handles the Double Spending Problem?

Flowchart of sending BTC from one buyer to other sellers

Bitcoin manages double spending fraud through the powerful technology i.e. The Blockchain. It works similarly to the monetary system or ledger of fiat currencies and traditional money’s, and records and keeps track of transactions in the network.

Typically, it takes about 10 minutes for a block or “a group of accepted transaction” to be generated. Blocks, as defined by Investopedia, are “files where data pertaining to the bitcoin network are permanently recorded.” It’s page of a record book, which, in Bitcoin’s context, is called the Blockchain.

Once a block is created, it’s immediately added to the blockchain and published to all nodes. Nodes send information to one another via the network protocol and are responsible for ensuring the system’s integrity. But how do all these complex components help in protecting your bitcoin from double-spending fraud? Let’s use an example to have an idea of how it works.

What does double spending look like?

Say you have 1 BTC, which you plan to spend on your dream adventure trip. You found a traveling agent that offers a trip plan and has agreed to get paid in BTC. After all the necessary talks and doing lot of research, you finally make the transaction with the vendor by sending your funds. However, without you knowing, the same BTC you used for payment was also used in purchasing certain products by a hacker who illicitly gained access to your bitcoin wallet. The transaction was made on same day and surprisingly, around the same time as yours. What’s going to happen next?

Chances are: either your adventure trip deal pushes through, OR the transaction made by the hacker gets confirmed first – meaning you’ll wave goodbye to your dream adventure trip ☹. This will depend on whose transaction will be confirmed first.

A confirmation on the blockchain indicates that “the transaction has been processed by the network and is highly unlikely to be reversed.” Transactions gain one confirmation “when they are included in a block and then for each subsequent block.” It is recommended to wait for a minimum of six confirmations, most notably to vendors, to be assured of the funds.

Both yours and the hacker’s transactions were sent into the unconfirmed and unverified pool of transactions. It’s important to know that, only the first transaction will be completed and verified by the block miners. This means that second transaction – if the miners consider it invalid due to the first transaction – will not push through, but will instead be taken out from the network.

Here’s another thing: in our example, both transactions (both yours and the hacker’s) were made on the same day and nearly within the same hour. Assuming that you made the first transaction, is it still possible that the hacker’s transaction will get confirmed first?

The answer? Yes. The second transaction can get the most number of confirmations if the miners simultaneously pull transactions from the pool and if it was pulled before the first one. In this case,  the transaction that gets the most number of confirmations first will get verified.

Common Double Spending Approaches

There are three typical ways a double-spending attack is made. Let’s briefly discuss each.

·       51% attacks: An attacker manages to take control of over 50 percent of the hash rate – or the measure of the Bitcoin network’s processing power.

·       Finney attacks: This happens when a miner, who has already mined a block, didn’t broadcast the mined block immediately to the network but spent it instead on another transaction, which then declines the payment.

·       Race attacks: This is when an attacker/hacker uses the same coin in two different transactions, but only one transaction gets verified and confirmed – leaving the other one invalidated.

Bitcoin’s Ultimate Weapon Against Double Spending Fraud

What makes Bitcoin Unique?

Its Base layer transactions on the blockchain are irreversible and final. This means that if someone intends to double spend bitcoin, this person has to go back all transactions made in the six confirmed blocks that were added after their transaction and reverse all of them. In the crypto sphere, this technique is known to be “computationally impossible.

Cryptocurrencies and other digital currencies use various electronic systems to prevent this potential flaw from taking place, and Bitcoin has its own defensive structure too.

With these tips in mind, you’ll know how to protect yourself and your bitcoin against potential double-spending attacks.

Thank you.

Read next