How Does Bitcoin Solve Double Spending? How to Prevent It!

  • by

The Bitcoin White Paper, released in 2008, launched the first peer-to-peer electronic cash system in the world. In 2009, Satoshi Nakamoto, the pseudonymous writer of the text, sent the first bitcoin customer through SourceForge and Bitcoin was born. At the heart of Bitcoin’s popularity was its ability to solve the double-spending problem that plagued all previous efforts to create digital currencies. In this article, we will clarify what is double expenditure and how it is avoided by the blockchain underpinning bitcoin.

Before Bitcoin, there was Bit Gold

Bitcoin was not the first attempt to create a digital cash network. Nick Szabo, a pioneer in digital currency, suggested Bit Gold in 1998 and introduced his proposals in a 2005 blog post. In retrospect, it can be assumed that Szabo has created Bitcoin from Bit Gold. Nevertheless, Szabo’s post-2008 Bitcoin reports show that his views of bitcoin were different from that of the unofficial founder of bitcoin, Satoshi Nakamoto. Crucially, the writings of Szabo indicate that he still treated Bitcoin as a value store rather than an exchange. One of the reasons why previous attempts to create digital currencies (such as Bit Gold) failed was that double-spending has not been addressed.

What is double-spending?

As the phrase suggests, twice the same money is spent. This is simply not possible with physical cash, such as coins and notes, and this is no problem.

Let’s take this example: you’re going to Walmart to buy food worth $20. You pay a $20 bill in cash and hand it over. Once the cashier places the cash in the drawer, you can not spend it again unless you steal it physically.

Why is double-spending an issue for digital money?

Cash is different from the digital money. When making a digital cash transaction you send the money to all’ nodes’ in the network (nodes are machines running the software that supports the currency). The transaction needs to be provided and checked by these nodes. Hence the problem: what should stop a person from copying and retransmitting a transaction?

Understanding the Blockchain

The blockchain underlying a digital currency such as bitcoin can not avoid double-spending alone. Alternatively, all of the different transactions concerning the cryptocurrency involved are put in the blockchain and are independently checked and secured by a confirmation process. In the case of Bitcoin and many other cryptocurrencies, these verified transactions are irreversible; they are publicly posted and retained in perpetuity.

Bitcoin was the first big digital currency to solve the double-spending problem. This was achieved through the introduction of this confirmation process and the creation of a standard, standardized leader method. It keeps records of time-stamped transactions since the development of the cryptocurrency in 2009.

A “node” is a permanently stored data file in Bitcoin words. All recent transactions are written into blocks, equivalent to an exchange transaction chief. Block information is added to the ledger every few minutes; the blockchain ledger is replicated in all network nodes. Users can access the bitcoin blockchain and only verify the transactions in terms of quantity. Information on the buyer’s and seller’s identities in every transaction are secured by high-level encryption which also protects the ledger against outside sources being disrupted. If the blockchain database is updated, all bitcoin wallets are updated.

Dealing With Double Spending

Imagine having 1 BTC and trying to spend it on two separate transactions twice. You can seek this by sending the same BTC to two different Bitcoin wallet addresses. All transactions are then entered into the database of unconfirmed transactions. The first transaction would be accepted through the validation process and then verified into the following row. Nonetheless, the second transaction would be regarded as invalid and not checked by the confirmation process. If both transactions are simultaneously removed from the pool for authentication, the transaction with the greatest number of confirmations is included in the ledger and the other transaction is discarded.

While this deals successfully with double expenditure, it is not without its problems. For example, the intended recipient of the second (failed) transaction would not fail itself, but wouldn’t receive the bitcoin he or she expected. Most merchants wait for at least 6 verified transactions (this means that after the transaction, 6 following blocks of transactions were added to the blockchain). The trader will safely assume at this stage that the transaction is legitimate.

There are other flaws in this program that may require attacks with double expenditure. For instance, if an intruder can control at least 51% of the network’s resources, he or she can spend double. If an attacker can somehow access a great deal of computational power, he or she can reverse transactions and create a separate, private blockchain. Nevertheless, bitcoin’s rapid growth has practically ensured that such an assault is unlikely

How Bitcoin Handles The Double Spending Problem?

With a validation mechanism and a distributed ledger (called “blockchain”), Bitcoin handles the dual spending problem, similar to the conventional cash monetary system.

The blockchain Bitcoin retains a time-stamped transaction leader chronologically ordered from the very beginning of its service in 2009.

A block (i.e. a set of transactions) is added to the ledger every 10 minutes. And all Bitcoin network nodes maintain a copy of this global leader (the blockchain).

See how the Bitcoin network prevents double spending:

Imagine you have 1 BTC which you are trying to invest two times.

You transacted 1 BTC to a dealer. Now you sign again and give the same 1 BTC to another Bitcoin address for the merchant to try to trick.

All transactions are carried out in the unconfirmed pool. But only your first transaction obtained confirmations and miners verified it in the next row. Your second transaction could not obtain enough evidence, as the miners found it invalid and therefore it was pulled out of the network.

But wait… what if the miners take both transactions simultaneously?

Once miners simultaneously remove the transactions from the pool, the transaction which receives the maximum number of network confirms will be included in the blockchain, while the other is discarded.

You may argue it is unfair to the merchant because the transactions could not be verified. Yeah, this could occur!!!

That is why traders will wait for at least 6 confirmations.

Here, “6 confirms” only means that 6 more blocks containing several other transactions were added after a transaction was added to the blockchain.

“Confirmations” are nothing but blocks that contain additional blockchain transactions. Each transaction and block is associated with the previous one mathematically.

All these confirmations and transactions are blockchain timeline, making them permanent and unmanageable.

If a merchant is provided the minimum number of confirmations, he/she can be sure that it was not a double expenditure from the sender.

Why can the trader be guaranteed?

Because the sender has to reverse all transactions in the 6 blocks added after his transaction, which is computationally impossible, to be able to repeat this coin.

How to Prevent Double Spending?

There are two methods of preventing replication–centralized and decentralized.

The Centralized Solution.

The unified approach to avoid duplication of expenditure is quite straightforward. It usually involves a trusted authority who records the balance of all in the system.

When Alice sends money to Bob, for instance, the transaction passes through the central authority (e.g. the bank) to make sure Alice has the funds it wants to spend. If all is in order, the central authority approves the transaction and the money is transferred.

The Solution Decentralized.

You have a central authority to verify transactions when dealing with a decentralized currency such as Bitcoin. Bitcoin, therefore, uses a mix of elements to resolve the problem of double-spending.

Preventing illegal transactions.

First of all, the Bitcoin transaction database, known as the Blockchain, is transparent and open to everyone. Each Bitcoin transaction ever made and every address balance can be reviewed by anybody.

It ensures that every machine with a copy of a blockchain (also known as a whole node) if Alice sends one bitcoin to Bob, must check the history of Alice’s transactions to make sure she has the one bitcoin to spend.

When Alice decides to cheat and produces a thin-air bitcoin, one of the many nodes validating transactions will quickly reveal it.

Preventing purchases concurrently.

But what if Alice gives the same coin to two people simultaneously?

Assuming that 50% of the nodes first received transaction A and the other 50% received transaction B first. transaction B How do we know which is true transaction and which is to be discarded?

The answer is straightforward: the transaction entering the ledger is first true. This is why it is often best to wait at least 1 confirmation before a Bitcoin transaction is considered full.
To determine the order of transactions, Bitcoin uses the Proof of Work (POW) consensus method. This system explains who updates the Bitcoin transaction database.

This is important because if there is no central authority, you need to decide on who switches the transaction leader. The entire process of updating the transaction directory is called Bitcoin mining. But, what happens if the mining process happened for both transaction A and transaction B simultaneously?

Suppose two separate miners were able to upgrade the ledger at the same time with a different transaction using the same fund source.
In this case, the blockchain is split into two branches (also known as the fork), and the next block of transactions will decide which previous block is true.

If the next block is also mined simultaneously, somehow, we’ll have to wait until the next day, etc.
If you want to be fully sure that in a rare case of a chance your Bitcoin transaction is not reversed, then wait for 6 confirmations for your transaction to arrive.
It is very doubtful (like super unlikely) that this fork would occur more than 6 times. In the end, however, there will be a clear winner and only one transaction will be verified.

Preventing the reversal of transactions.

There is a special type of double-spending attack called a 51% attack. This is achieved when a single company holds over 50% of the mining power of the network and can effectively control the official version of the ledger.

In this case, the attacker may spend coins on a single version for this payment, obtaining goods or services. Later a different version of the headline was created by the attacker when the initial transaction did not exist and the payment was recovered.

The only way to prevent an attack by 51 percent is to ensure that the network is sufficiently decentralized and has enough computing power to make it essentially impossible to obtain more than 50% of its hash rate.
In the case of Bitcoin, 51 percent is highly unlikely, but this kind of attack happened with smaller coins.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.