With continually growing popularity, Bitcoin has become world’s first fully functional digital currency in the crypto space. Even before Bitcoin came into being, many attempts were made to create a more maintainable digital monetary system. However, these attempts failed, as the transactions couldn’t be copied and were being spent twice.
After Bitcoin came into being, it was able to survive in the market, as it could solve the double spending problem. Now you would be wondering what is this double spending? Let’s have a look.
What is Double Spending?
As the name suggests, Double spending is spending the same currency twice. Bitcoin transactions have a likelihood of being copied and rebroadcasted, thus creating a possibility that the same Bitcoin might be paid twice.
For example, if you buy a beer can, you pay the cash at the beer counter, and in return, the guy at the desk confirms and verifies your payment. Nevertheless, with digital currency like Bitcoin, if the verification process is missing, it can lead to double spending. This means anyone can copy the digital money that you have and pay it somewhere else.
But the good part is Bitcoin solves the problem of digital money being copied and getting spent twice. Let’s see how Bitcoin handles the Double Spending problem.
How Bitcoin Handles the Double Spending Problem?
Just like a traditional cash monetary system, Bitcoin brings a confirmation mechanism into play and maintains a universal ledger, which is known as blockchain. Since its inception in 2009, Bitcoin’s blockchain has been keeping a record of the transactions, which are chronologically-ordered and accurately time-stamped.
Every ten minutes, a group of transactions (or a block) is added to the ledger. Each node on the Bitcoin network maintains a copy of this global ledger, which is also known as a blockchain.
But how does Bitcoin prevent double spending? Let’s check an example.
For instance, you have 10 BTC, and you want to spend it twice. You make your first transaction of the 10 BTC with a merchant and again try to send the same 10 BTC to another address. Both these transactions move to the unconfirmed pool of transactions. However, only the first one gets confirmed and is verified by the miners. The second transaction does not get sufficient confirmations due to miners judging it as invalid, so it is pulled out from the network.
But what if both the transactions are taken concurrently by the miners?
If in case, miners pull the two transactions at the same time from the pool, then the transaction which gets maximum confirmations from the network gets incorporated in the blockchain, and the other gets discarded. However, it might look unfair to the merchant, as the transaction might fail in getting confirmations. This is the reason it is always advisable for merchants to wait for at least six confirmations.
Usually, six confirmations mean after a transaction is added to the blockchain, six more blocks including several other transactions will be added post that. So, a confirmation is like more blocks containing more transactions being incorporated in the blockchain, where each transaction and blocks will be mathematically related to the previous one.
The good part is every confirmation and transaction is time-stamped on the blockchain. So, these are irreversible and cannot be tampered. So, if you are a merchant and you receive maximum transactions, you can be assured that the currency was not double spend by the sender.
What makes it so favourable for the merchant?
To be able to double spend those 10 BTC, you will have to go back and reverse all the transactions in six blocks that were added after the transaction was made, which is practically impossible.
How does Double Spend Attack Happen?
Race Attack: If an attacker sends the same BTC in rapid succession to two different addresses, then only one of them gets included. If you are a merchant and you don’t wait for six confirmations of the payment, there is a 50% chance that you have received a double spent coin. So, in this case, you won’t receive the money.
Attack 51%: If the attacker captures 51% of the hash power of the network, then double spending might happen. Hash power is the computational power that verifies the transactions and blocks. If an attacker has control over it, then he can quickly reverse the transaction and make a private blockchain, which other miners might consider as real.
However, so far, no such attacks have been reported. Controlling 51% of the network is not only cost intensive, but it also depends on the current difficulty of mining, the price of hardware and electricity cost. All of this makes it infeasible to acquire.
The blockchain is an open and immutable, global ledger, which ensures that transactions are finalised when its inputs are confirmed by other miners. These confirmations make each bitcoin/altcoin unique and its following transactions, legitimate. So, if a transaction is confirmed in Bitcoin/altcoin blockchain, it is impossible to double-spend it. If a transaction has more confirmations, the harder it will become to double-spend the bitcoins/altcoins. Bitcoin solves this double-spend problem, and this is what makes it more viable. So, if you are a merchant and want to prevent yourself from a double spend, make sure you wait for enough confirmations, rather than losing your money.