You are at: Home » Double Spending

What is Double Spending?

By: Ofir Beigel | Last updated: 1/11/21

One of the main issues any digital currency faces is double spending. This post explains exactly what the double spend problem is, and how to prevent it.

What is Double Spending Summary

Double spending is the act of trying to spend the same digital currency twice by creating duplicate transactions. This issue is one of the main obstacles a digital currency needs to solve in order to make sure it is not being abused, and that it maintains its value and trust.

Bitcoin solves the double spend problem through the use of a public ledger that is constantly monitored by network participants, and through the Proof of Work consensus mechanism.

That’s double spending in a nutshell. For a more detailed explanation keep on reading, here’s what I’ll cover:

  1. Double Spending Explained
  2. How to Prevent Double Spending
  3. RBF – “Legit” Double Spending
  4. Conclusion

1. Double Spending Explained

Since Bitcoin transactions are a digital file, it’s actually possible to duplicate transactions and spend the same Bitcoin twice. This issue of “copying and pasting” is a weakness any digital currency faces (even fiat currencies in their digital form).

Here are some examples of how you can double spend a digital currency:

  1. You can “copy” a coin and send it to someone while still retaining the original.
  2. You can simultaneously send the same coin to two different people.
  3. You can reverse a transaction that’s already been made after receiving the goods paid by it, hence keeping the goods and the money.

The double spend problem is a serious issue for any digital currency since it can create an inflated money supply which quickly erodes the value of the currency and the trust in it.


2. How to Prevent Double Spending?

There are two ways to stop double spending – a centralized way and a decentralized way.

The Centralized Solution

The centralized solution to prevent double spending is pretty simple. It usually involves a trusted authority that holds a record of everyone’s balance in the system.

For example, when Alice sends money to Bob, the transaction goes through the central authority (e.g. bank) that checks its ledger to make sure Alice has the money she wants to spend. If everything is in order, the central authority authorizes the transaction and the money is transferred.

The Decentralized Solution

When you’re dealing with a decentralized currency like Bitcoin, you don’t have a central authority to validate transactions. Therefore, Bitcoin uses a mix of elements to solve the double spend problem.

Preventing Fraudulent Transactions

First of all, the Bitcoin ledger of transactions, known as the Blockchain, is public and visible to all. Every Bitcoin transaction ever made and every balance of every address can be inspected by anyone.

This means that if Alice sends one Bitcoin to Bob, every computer that holds a copy of the blockchain (also known as a full node) will verify the history of Alice’s transactions to make sure she indeed has that one Bitcoin to spend.

If Alice tries to cheat and creates a Bitcoin from thin air, she will quickly be exposed by one of the many nodes validating transactions.

Preventing Simultaneous Transactions

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

Assuming 50% of the nodes received transaction A first, and the other 50% received transaction B first. How do we know which transaction is valid, and which to discard? The answer is simple: The transaction that enters the ledger first will be the valid one.

That’s why it’s always recommended to wait for at least 1 confirmation before considering a Bitcoin transaction as complete.

In order to decide the order of transactions, Bitcoin uses a consensus mechanism called Proof of Work (POW). This mechanism describes the rules of who gets to update the ledger of Bitcoin transactions.

This is important since when there’s no central authority, you need to have a consensus about who gets to make changes in the transaction ledger. The whole process of updating the ledger of transactions is known as Bitcoin mining.

However, what happens if the mining process somehow happened simultaneously for both transaction A and transaction B?

Let’s assume that two unrelated miners managed to update the ledger at exactly the same time, each one with a different transaction that uses the same source of funds.

In this case, we will have 2 branches of the blockchain (also known as a fork) and the next block of transactions to be mined will determine which previous block was valid.

If the next block, in some magical way, is also mined simultaneously, we will have to wait until the next block, and so on.

If you want to be completely sure your Bitcoin transaction won’t be reversed in such a rare case of coincidences, you should wait until 6 confirmation arrives for your transaction.

It’s highly unlikely (like super highly unlikely) that this fork will happen more than 6 times. So, in the end, we will have a clear winner and only one transaction will be confirmed.

Preventing transaction reversal

There’s a special kind of double spend attack that is called a 51% attack. This happens when a single entity gains over 50% of the network’s mining power and can effectively control which version of the ledger is the legitimate one.

In this case, the attacker can spend coins on one version, obtaining goods or services for this payment. Later on, the attacker creates a different version of the ledger where the original transaction doesn’t exist and retrieves the payment to his possession.

The only way to prevent a 51% attack is to make sure the network is decentralized enough and has enough computational power to make it basically impossible to amass more than 50% of its hashrate.

In Bitcoin’s case, a 51% is highly unlikely, but with smaller coins, this type of attack has happened.


3. RBF – “Legit” Double Spending

One form of “legit” double spending is Replace By Fee or RBF for short.

RBF is a function embedded in certain Bitcoin wallets (e.g. Electrum) that allows you to rebroadcast a transaction that is still unconfirmed, in order to get it confirmed faster.

In some cases, Bitcoin transactions are sent with a network fee that is too small to incentivize miners to pick them up. This can get your transaction stuck inside the mempool, waiting to be confirmed for a very long time.

RBF allows you to rebroadcast the transaction with a higher fee, effectively trying to double spend your money, so the miners will pick up the new transaction and the old one will get canceled.


4. Conclusion

Double spending is a major issue that needs to be addressed when dealing with digital currencies. Fortunately, it seems that Satoshi Nakamoto, the inventor of Bitcoin, managed to build a mechanism to prevent it from happening even in a decentralized network.

You may still have some comments or questions. If so, make sure to leave them in the comment section below.

Free Bitcoin Crash Course

Learn everything you need to know about Bitcoin in just 7 days. Daily videos sent straight to your inbox.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
We hate spam as much as you do. You can unsubscribe with one click.
We hate spam as much as you do. You can unsubscribe with one click.

13 comments on “Double Spending”

Leave a Reply

Your email address will not be published.

    1. Hi Neeraj, this transaction fee is just too small, it might never get confirmed. You can use a transaction accelerator to have it confirmed for an extra fee.

  1. I got an idea of double spending in Bitcoin-Blockchain but i have a scenario
    Scenario – Let say Alice has only 10 BTC to spend and buys a merchandise of 10 BTC from Bob and initiate the payment in Bitcoin. Merchandise doesn’t wait for the payment to confirm and send the merchandise to Alice.
    But At the same time Alice initiate the same 10 BTC payment to her own account (having different BTC address) and tricked the network. This is the same case as of double spending.
    I know only one transaction would be confirmed by the network but if that would be second one then in that case Bob has already shipped the merchandise but he will not receive the money.
    What should be done in this case ? Shall Bob wait till transaction gets confirmed ? As Transaction confirmation may take 10 min to 1 hr (average) ?
    Please help me understanding this scenario if this is valid.

  2. Zsofia - 99Bitcoins support

    Hi, you cannot resend a Bitcoin until it has been confirmed on the blockchain, otherwise it will be double spending as it just happened. He will be able to send once the first transaction has been confirmed, it might take couple of days if the fees were low if that was not already a double spending. Otherwise eventually the transaction will be cancelled once the transaction is dropped off by all miners and will be rejected on the blockchain, but also needs time. At this point I don’t think so that you have much choice, just wait.

Scroll to Top