Earlier transaction: Send 1 btc @ lower fee
Later transaction: Send 2 btc @ higher fee.
(1) Would it be correct to say that the 2 btc transaction will replace the 1 btc transaction?
(2) How does the bitcoin network distinguish this from there being 2 separate transactions eg. to send a total of 3 btc? Assumption here is that the UTXO has more than 3 btc.
Thanks.
1) The second transaction doesn't replace the first one since they both are in the pool of unconfirmed transaction. Both are valid until one of them gets confirmed. The reason the higher fee transaction may be confirmed faster than the previous low fee one is that miners are usually incentivized to maximize their profits and strive to include transactions with a higher fee.
2) The thing is you can't spend part of the UTXO. So if your UTXO contains 3
BTC, and you need to buy a cup of coffee worth 1
BTC, you end up sending 1
BTC to the coffee shop owner and 2
BTC back to yourself. That transaction will destroy the old 3
BTC UTXO and create two new ones 1
BTC for coffee 2
BTC as change. For simplicity, I didn't include transaction fee.
EDIT: Okay, you bought your cup of coffee and now you have one UTXO with 2
BTC. But the transaction is still shown as unconfirmed. What can you do to make it confirmed faster? You can send your 2
BTC to your another address and set higher fees. By doing this, you will create a chain of unconfirmed transactions. Miners will notice that your last transaction is paying high fees and therefore will include the whole chain in the block.