Double-spending refers to the event where cryptocurrencies are spent twice across two transactions. It occurs when the blockchain network is disrupted and a copy of the crypto transaction is made to make it look like a legitimate transaction.
what is the double spend problem?
Imagine that you can use a dollar to pay for an item in one store and use the same dollar to pay for another item in a different store.
That is impossible right? Digitally though, this happens with cryptocurrency transactions. This is referred to as the double spend problem.
Transactions with cryptocurrencies have to be confirmed as genuine before they are added to blocks.
This can be done using different consensus mechanisms, including Proof-of-Work and Proof-of-Stake. In some cases, a person can spend their wallet balance twice.
For example, Bob has one dollar in his wallet and he needs to send the whole balance to Alice (assuming there are no fees).
After sending the whole amount to Alice, he then remembered he needed to send the same amount to Carol. He then initiates another transaction, sending his wallet balance to Carol.
If Bob initiated the transaction to Carol before the one to Alice is confirmed, it can result in a double spend. That means Bob spent his one dollar balance twice, hence the name “double spend”.
This is a common occurrence on some cryptocurrency networks. It is referred to as an attack because some crypto users do it intentionally to cheat.
It is advisable to get several confirmations (atleast 6) on a transaction before confirming receipt.
examples of double spend attacks
Double spend attacks come in various forms. However, the most commonly seen type is a 51% attack.
This is a situation in which someone with control over a large share of the blockchain’s hash power illegally double-spends coins.
They reverse confirmed transactions and then spend the coins in a second transaction as explained with Bob, Alica and Carol.
Examples of such attacks have been seen in crypto networks such as Ethereum Classic. Ethereum Classic is a fork of Ethereum that was created in 2015. The network suffered 3 of such attacks in August 2020 alone.
As a measure to prevent future attacks, the network introduced Modified Exponential Subjective Scoring (MESS) which reduces the block maturation time for Ethereum Classic to 500 new blocks (approx. 2 hours). This in principle makes it more costly for miners to launch another attack in the future.
Bitcoin Gold, one of Bitcoin’s many forks, was also hit by a 51% attack in May 2018. The attack was launched by someone who remains unknown till today.
Another set of attacks occurred on the network in January 2020 that led to the loss of $70,000 in double spends. These are just a few of the cases of double spend, but Bitcoin has never suffered such an attack.
There was an alleged double spend attack on the Bitcoin network in January 2021. You may have heard of it if you have been following the developments. However, experts say it was not really a 51% attack.
This is because rather than the same coins being sent in two different transactions, the same transaction was recorded twice in two separate blocks. This is a common Bitcoin blockchain split.
How does Bitcoin Solve The Double Spending Problem?
Bitcoin was the first cryptocurrency ever created, which means it has been around for longer than any other. However, it has never suffered a double spend attack.
Before we go into why this is so, let’s take a brief look at how 51% attacks work for example.
For cryptocurrencies that use Proof-of-Work consensus like Bitcoin, miners confirm transactions. There is a general rule in crypto that it takes at least 51% of the hash power on a blockchain to launch such an attack. This means more than half of the miners have to agree to reverse a transaction. Why has this never happened on Bitcoin?
Bitcoin network is designed such that if a user spends the entire wallet balance twitch, only the transaction with the first confirmation gets added to the block while the other is discarded.
The confirmed transaction then gets a timestamp, making it impossible to reverse.
The enormous amount of energy required to mine Bitcoin also discourages this. If a miner fakes a transaction, they will need to go back and mine previous blocks to make the transaction look real.
Meanwhile, more blocks are added approximately every 10 minutes, making it unthinkable to do such a thing. This system serves as a deterrent to any miner that may want to launch such an attack on the bitcoin network.
In other words, the Bitcoin network is built in such a way that it makes a double spend attack very costly. Nobody wants to lose so if the miners figure that they will be carrying out such an attack at a loss, they will be less likely to do it.
This is a method that other blockchains such as Ethereum Classic have adopted in a different way. Since then there has not been another such attack on the network. It is however not a guarantee of safety. In the end, the real deterrent is the miners deciding to uphold the idea behind blockchain technology, which is transparency and infallibility of the system.
Can bitcoin be double spent?
Bitcoin clearly has a mechanism that reduces the possibility of a double spend attack. However, this does not mean the network is immune to double spend attacks.
As mentioned earlier, if a miner or group of miners can convince others to join them and make up upto 51% of the miners, they can reverse transactions and create a new blockchain.
However, so far, the network has evolved very rapidly over the years to ensure that such is not likely to happen.
There were recent concerns that China alone holds more than 60% of all Bitcoin miners and can lead to such an attack.
The concern stemmed from the fact that one of Bitcoin’s biggest strengths is the decentralization of miners.
In spite of the concentration of miners in China, no such attack has happened.
What happens if you double spend Bitcoin?
With the way Bitcoin was set up, it is unlikely that miners will be able to successfully launch a double spend attack. That said, it is still not impossible for an attack of the sort to happen if enough hash power is acquired.
In the event that this happens, those who orchestrated the attack are able to steal Bitcoins. Since they interrupt the network for some time, they are able to redirect transactions sending Bitcoins to their wallets.
This can be done severally by removing the history of the diverted transactions from the ledger, making it look like there were no such transactions to a different wallet.
Another scenario is for them to send a fake copy of the transaction to the intended receiver to make it look like the transaction actually occurred. The funds will not be deposited in the wallets though because they have been diverted.