How do we "exchange coins on one blockchain for those on the other"? With Segwit and BIP-148 coming, I have been trying to figure out what's exactly gonna happen with Bitcoin after August 1, by watching videos and reading articles. One thing (among many others) confuses me ..

Some are saying that you can exchange Bitcoins on one blockchain (say, the Legacy blockchain) for Bitcoins on the other (say, the BIP-148 blockchain). I don't understand how this can be done. I actually don't think that this would be possible. This is my reasoning:

Say I have 20 BTC on the (Legacy) blockchain before August 1. Now, August 1 arrives, and we have a BIP-148 soft fork. Now, I have 20 BTC on both, the Legacy blockchain and the BIP-148 blockchain. Now, to "exchange Bitcoins on one blockchain for other" (or for any other transfer), I have to make a transaction - a send or a receive.

Suppose, I send 15 BTC to some person P. This transaction will be broadcast to all the nodes/miners in the network, irrespective of the fact whether that node/miner runs BIP-148 software or not. If:


A BIP-148 miner solves the transaction first: That block will be attached to both the blockchains. The Legacy miner will stop trying to solve that transaction.
A Legacy miner solves the transaction first: The block will be attached to the Legacy blockchain, and all the BIP-148 nodes will reject this block. But, BIP-148 miners still have this transaction in their mempool. They will keep on trying to solve it and eventually will solve it.


In both of the above cases, the BTC balance of both myself and person P is the same in both the blockchains.

The only way, it seems to me, to have different balances for a particular account (public key), is, if someone tries to do double-spending. (I have arrived at this conclusion after doing some analysis.)

So, how do exchange coins on one blockchain for coins on the other, reliably?
There are two ways to avoid transaction replay (besides something being built into the fork to begin with). You can taint your coins or double spend.

Tainting your coins requires you to get access to coins created after the fork on at least one of the chains. If you create a transaction which includes an input from a coinbase transaction created on the BIP 148 chain, then that transaction is invalid on the non-BIP 148 chain. And vice versa. Then any transaction which spends from this tainting transaction will only be valid on one chain.

The other way is to perform a double spend. Let's assume that the BIP 148 chain has less hashrate (and thus slower blocks). You make a transaction which signals for RBF which is likely to confirm in the next block on the non-BIP 148 chain. Since the non-BIP 148 chain produces blocks more quickly, your transaction will likely confirm on the non-BIP 148 chain before it does on the BIP 148 chain. Once you have a confirmation on the non-BIP 148 chain, create a double spend which pays a higher fee (to take advantage of RBF) and sends the coins to a different address. This transaction will then confirm on the BIP 148 chain since it is invalid on the non-BIP 148 chain and has replaced the original. Your coins are now separate and won't be at risk for transaction replay.