If someone is sending bitcoin with low transaction fees and then sends the same bitcoin with higher transaction fees before the previous one is confirmed, so it is obvious that miners will pick the second one, so ethereum has nonce value of each transaction which avoids this, but how does bitcoin avoid it?
-
Nonce doesn't prevent the scenario you mentioned in Ethereum. You can still create two transactions with the same nonce and the one with the higher fee will be taken by miners. Though wallets generally don't presume bad intent, so they just increment the nonce. Nothing prevents you from creating two transactions with the same nonce twice, manually by hand. In that case, only one will be mined/added to a block. The one with the higher fee.– The Quantum PhysicistMar 28 at 13:12
2 Answers
If someone is sending bitcoin with low transaction fees and then sends the same bitcoin with higher transaction fees before the previous one is confirmed, so it is obvious that miners will pick the second one
By default, the miner won't pick the second one, except the previous one had Opt-in RBF enabled.
However, technically or theoritically speaking, a miner always has the ability to pick any transaction he likes into his block template, so that he could mine such transaction(s) into his block. It's just the matter of whether his block would be widely accepted by the network (including other miners, non-mining full nodes which the wallet relied on, etc).
ethereum has nonce value of each transaction which avoids this, but how does bitcoin avoid it?
I don't know much about Ethereum. As far as I know, the UTXO model itself is the equivalent of the nonce value, since each UTXO (uniquely identified with TXID and output index) could be spent only once, otherwise it would be an invalid transaction or block.
Note that the nonce value/UTXO model and double spending by forking the chain are two distinct problems.
Without the nonce value/UTXO model, even an individual chain itself cannot rule out double spending or replayed transactions, which is actually inflation in bitcoin, or replay attack in ethereum (the replayed transaction would make the victim make another unexpected repeated payment, so he would lose money).
However, even with nonce value/UTXO model, the attacker can still produce forked chain to "rewrite the history" (in such case, the previous transaction would be actually discarded, which generally means the previous legitimate payment would be maliciously withdrawn), which is the reason why we need a consensus mechanism like proof-of-work.
it is obvious that miners will pick the second one, so ethereum has nonce value of each transaction which avoids this, but how does bitcoin avoid it?
Replace-by-fee is essentially Bitcoin creating a feature "RBF" on top of some behavior "A" (miners preferring the second transaction, or actually whichever transaction is economically preferable for the miner) refusing to consider the behavior "A" as a drawback, therefore consolidating "A" as a feature.
Double spending is still prevented by Bitcoin's high hashpower and by users waiting the number of recommended confirmations, both before and after replace-by-fee was invented.
A scenario requiring the possibility of accepting unconfirmed transactions as final without losing funds requires, as you know, a different crypto asset. Use different crypto tokens and networks for different needs. Bitcoin is a network for settlements ledger, not a network for fast payments.