In order to get a general insight on what does double spending mean, you need to first understand how
Inputs and Outputs work in Bitcoin. Those are the important aspects considered while double spending an already spent output. In simple terms, a double spending is creating an alreadey spent money and spending them for another time. Breaking down further, they are like
printing your own fake bank notes.A double spending in fiat money works like, You pay the merchant with the money after that you create your own money with the same Sl. No and spend that note in the public, by this way the money is created twice. But since, the fiat money is unlimited and there isn't any specific limit set on them there wouldn't be much impact in the economy. But digital currencies follow the pattern of having a fixed supply, hence creating any such additional money would not be considered good to the economy of digital money.
Merchants commonly wait for the confirmations to take place in the bitcoin network, since they prevent the double spending to take place. Confirmations are such that, the transactions are mined and added to the block and no such additional instances of double spending can take place or more simply even though the customer creates a transaction with already spent input they won't be confirmed by the network. There are several ways to perform a successfull double spend in the network.
It included a link to double spend attacks which I interpret to mean two transactions being sent simultaneously.
- The one you are mentioning about is called as Race Attack and they are a form of double spending a transaction actually. Here the payee sends two transactions, one to the merchant and the same output to himself. If the merchant accepts the payment with 0 confirmations, he would probably be fooled by this. In most of the cases, this can happen when the merchant node has direct connection with the payee node through the incoming connections. The payee sends a transaction to the merchant legally through his node, and simultaneously broadcasts one to the network. If the merchant accepts the fraudulant transactions which has a 0 confirmation sent throught the incoming connection, there is a possibility for the other transaction broadcasted to the network to get confirmed and by which the payment gets reversed back to the payee.
Question 2: How is a 51% attack different from a double spend attack? Or are they the same thing.
- NO. A 51% Attack is a type of attack to perform a double spending. They are not double spending. A 51% attack is really difficult to perform considering the current amount of hashrate. Though they could have been done during the early days of the network. A 51% attack can be performed when the single miner controls more than 50% of the total hashpower of the network. There is a common rule that the Longest Chain is always considered as the Valid Chain by the network. If the miner controls 51% of the hashrate, he could mine the blocks faster than the current chain, and by this way he can replace the older chain and make his alternative chain the longest one. This chain will be considered by the network as a valid chain,by this way he can reverse the already spent outputs and can perform a double spend. At the current hasrate, a single miner requires to have more than 20 million TH/s to perform a 51% attack which is quite impossible. If this were to performed, it would damage the whole bitcoin network, so possibility for this to take place is very low.
- A third type of attack is a Finney Attack proposed by Hal Finney.
Replace-by-fee is a proposed solution to help the transactions to be processed faster. As explained by nc50lc the older transactions is replaced by the transaction with new fee. Here the miners first accept the tx with higher fee and mine them to a block. Eventually one with lower fee will be rejected by the network considering that they have already been confirmed by the netork.
P.S I write technical posts as simple as possible so that even the non-technical people can understand. I hope this helps you.