Blockchain Tutorial

Blockchain Tutorial History of Blockchain Blockchain Terminologies Working of Blockchain Blockchain vs DLT Blockchain Versions Smart Contracts Blockchain Applications Cryptography Role of Bitcoin Miners Blockchain Hash Function Bitcoin Basic Component Blockchain Block Hashing How to Block Hashes Work in Blockchain Blockchain Pow Coinbase Transaction Key Concepts in Bitcoin Key Areas of Blockchain Blockchain Cryptocurrency Blockchain DAO Blockchain Double Spending Blockchain Bitcoin Cash Bitcoin Forks and SegWit Blockchain Merkle Tree Difference between Blockchain and Database Bitcoin Mitigating Attacks Who sets the Bitcoin Price Getting Started with Bitcoin How to choose Bitcoin Wallet Sending and Receiving Bitcoin Converting Bitcoins to Fiat Currency Ethereum 2.0 Blockchain Data Management Steps to become a Blockchain developer Smart Contracts Advantages of Blockchain in healthcare Decentralized Voting System using Blockchain Demur-rage currencies in Blockchain How can Blockchain Technology help IoT to reach its full potential Project Ideas on Blockchain for Professionals Consensus Algorithms in Blockchain Top 10 Blockchain Project Concepts Uses of Blockchain Obtaining Free Test Ethers What does a Blockchain contain What does the IT industry mean by BaaS Top Blockchain Project Ideas for Beginners


Introduction and Features of Cryptography DNA cryptography ECB Mode in Cryptography Elliptic curve in cryptography Format String Vulnerabilities in Cryptography and Network Security Kerberos in Cryptography and Network Security Blowfish Algorithm in Cryptography Data Encryption Standards Feistel Cipher in Cryptography HMAC Algorithm in Cryptography IP Security in Cryptography ElGamal Algorithm ElGamal Cryptosystem What is IDEA Advantages of Cryptography Role of Bitcoin Miners Blockchain Hash Function Blockchain Merkle Tree Blockchain Pow Coinbase Transactions Consensus Algorithms in Blockchain Converting Bitcoins to Fiat Currency Decentralized Voting System using Blockchain Demur-rage currencies in Blockchain Difference between Blockchain and Database Difference between Symmetric and Asymmetric Encryption Ethereum 2.0 Getting Started With Bitcoin How can Blockchain Technology help IoT to reach its full potential? How does Digital Signature Work Advantages of Blockchain in healthcare Basic Component of Bitcoin Bitcoin Forks and SegWit Bitcoin Mitigating Attacks Blockchain Bitcoin Cash Blockchain Block Hashing Blockchain Cryptocurrency Blockchain DAO Blockchain Data Management Blockchain Double Spending What does Blockchain contain? What does the IT industry mean by BaaS (Blockchain as a Service)? Who sets the Bitcoin Price? Working of Block Hashes in Blockchain How to Choose Bitcoin Wallet? Key Areas of Blockchain Key Concepts in Bitcoin Obtaining Free Test Ethers for the Rinkeby Test Network on the Ethereum Blockchain Project Ideas on Blockchain for Professionals Sending and Receiving Bitcoin Top 10 Blockchain Project Concepts Uses of Blockchain What do you need to do to become a Blockchain Developer? Blockchain Technology-Introduction

Blockchain Double Spending

When the money is spent twice, we call it double-spending. We know any transaction can occur in two different ways 1st way is offline mode and 2nd way is online mode.


There is no involvement of physical currencies instead we use digital currencies, so it is called an online transaction.


This involves physical cash or currencies in it, and it is known as offline transactions.

Let us take an example:

Go to a restaurant or hotel and order a coffee worth $10 and pay the bill in cash. The service provider in the restaurant or hotel confirms that you have paid the bill, and in return for that, he gets a coffee for you. Now, if you wish to spend the same $10 in some other place to make another purchase, it is not possible. But what if I say it can be possible. It means that the person can use $10 or more same amount of cash more the 1 time and this kind of problem is called Double Spending - when money is spent twice.

Double Spending can never take place in the case of offline mode transactions (physical cash). But Double Spending can occur in the case of online mode transactions like Bitcoin. In Bitcoin, these kinds of transactions can take place and possibly be rebroadcast or copied. & it is possible that the same BTC can be spent one or more times by the owner of the BTC.

Recognizing Double Spending

To comprehend double-spending, it is necessary first to grasp how the Blockchain operates. When a block is formed, a hash—or encrypted number—includes a timestamp, information from the preceding block, and transaction data when a block is created. This data is encrypted using a security technique similar to Bitcoin's SHA-256 algorithm.

The previous block is closed when miners have validated the information in it (in proof-of-work consensus), and the previous one's timestamp, transaction details, and hash are used to construct a new one. A Bitcoin is given to the miner whose machine validated the hash.

To double spend, a secret block must be mined faster than the Blockchain itself is created. They'd have to add that chain into the network first.

Attacks with Double Spending

A 51 percent assault, which occurs when a miner controls more than 50% of the computer power that validates transactions, creates blocks, and awards cryptocurrency, is the most serious threat to Blockchains.

This user  or users will be able to dictate transaction consensus and control the distribution of currency if they control a majority of the hashing in the Blockchain. This is extremely rare with more prominent cryptocurrencies like Bitcoin due to many miners and high hashing difficulty; nonetheless, new or forked cryptocurrencies with smaller networks are vulnerable to this attack.

The unconfirmed transaction attack is most typically used to deceive cryptocurrency users. You should not accept one of these transactions if you see one.

How to solve the Double Spending in Bitcoin?

To solve the Double Spending problem in Bitcoin, Bitcoin implements maintaining a universal ledger and confirmation mechanism called a Blockchain.

Assume that you have 2 BTC and are attempting to use them twice. Suppose you made a 2 BTC transaction to Akshay and again you have sent the same 2 BTC to Rony. So totally, you did two transactions, and both the transactions go into a pool of unconfirmation. A group of unconfirmed transactions is referred to as a pool of unconfirmed transactions. The unconfirmed transaction is the transaction that is not picked by anyone. The transaction that had the most confirmations and was validated by miners will now be valid. Another transaction that received insufficient confirmations will be removed from the network. Transaction T1 is valid in this case, and Akshay will receive the Bitcoin.

What happens if the miners process both transactions at the same time?

Assume that two separate miners choose both transactions simultaneously and begin building a block. Akshay and Rony will wait for their transaction to be validated after the block has been verified. The transaction that received the most confirmations will be validated first; then, another will be taken from the network.

If both Akshay and Rony receive the initial confirmation at the same moment, a race between them will begin. As a result, whatever transaction has the most network confirmations will be included on the Blockchain, while the other will be destroyed.