Ever since the Bitcoin scaling debate emerged, it has become a hostile environment with various groups trying to push their political views on everyone.
Both groups are very loud and demand Bitcoin to change significantly without broad technical and network consensus.
In the event of a chain split it may be desired to split your bitcoins in both chains to protect against replay attacks.
Replay "attack" happens when a transaction on one chain is also minted by a miner on the other chain effectively spending both coins. To mitigate the risk it's advised to split coins so the UTXO set is different for both chains. This will make any further transaction valid on one but invalid on the other one.
There is no guarantee, that any of the following methods will successfully split your coins, though.
Therefore as a safety precaution, I advise you to try splitting coins within your own wallets. If the split doesn't work at least you'll still own your coins (minus transaction fees).
When splitting the coins, you will absolutely want to run a full Bitcoin node to make sure you're on the right chain.
In this particular case, you will need two Electrum servers and two Bitcoin full nodes. One for each chain.
Please note: nLocktime transactions can no longer be included in Mempool before the given block height.
The chances are two chains will diverge in block height. It means that one of the chains will have more PoW (proof of work) done than the other.
If that's the case, wait until a difference between chains is let's say 10 blocks with the higher block height being X+10 = 470490 blocks. Let's call the longer chain LegacyChain and the shorter one NewChain (the block height of X = 470480 blocks).
To split coins, we will have to create two transactions, the first one being of the type "nLocktime". An nLocktime transaction will not be included in a block until the chain reaches the needed block height.
Create the first transaction TX1 on LegacyChain with a block height of X+10 spending all coins to an address A1.
This transaction should be picked up by LegacyChain miners in no time given the sufficient fee was paid. Because the block height is higher than the current height on NewChain, it can't be immediately included in a NewChain block.
Wait a few minutes for TX1 to propagate.
Now, create the second transaction TX2 on NewChain spending all coins to a different address A2. Don't forget about a sufficient fee too.
Ideally, you could wait with sending TX2 on NewChain until TX1 confirms. However, don't wait longer than the block height of X+10, otherwise, you're risking TX1 being picked up by NewChain miners too.
If either of transactions is minted on both chains, repeat the whole process until your coins are successfully split.
How to make nLocktime transaction
Electrum doesn't support creating nLocktime transactions but because last 4 bytes of a raw transaction are reserved for "locktime", we can easily edit the transaction.
Open Electrum wallet that is connected to LegacyChain and create a transaction.
Make sure to include a high enough fee so it's confirmed ASAP.
Don't send it yet. Click "Preview" instead.
Click "Copy". Don't sign nor broadcast yet!
Go to my nLocktime tx editor (temporarily not available) and paste the copied address in the first field.
Open the latest blocks list, find the current block height e.g.: 470480 and add 10. The block height we're looking for is then 470490.
Go back to the editor, type the block height in the second field and click "Calculate".
It will strip last 4 zero bytes of the raw transaction and append the desired block height as a little endian number at the end. Copy it.
Go back to Electrum, open
Tools -> Load transaction -> From text and paste it there.
The new tx window will open with a new "LockTime" of 470490.
Make sure inputs, outputs and fees are correct. Sign the transaction.
Broadcast the transaction after the given block is mined but before the same block height is reached on NewChain. Otherwise, you risk having the same transaction mined on both chains.
How to send TX2 on NewChain
Open "Network settings" by clicking on the green circle icon.
Make sure "Select server automatically" is unticked. Type an IP address and port of the NewChainserver and click "OK".
New block headers will be downloaded and the LegacyChain transaction shouldn't be listed in the "History" anymore.
Wallet->Addresses and copy the last address from the "Receiving" list.
Create a new transaction and spend all coins to this address.
Wait for both transactions to be confirmed - 6 confirmations should be enough.
Now, create a new wallet in
File -> New/Restore, select
Standard wallet -> Create a new seed and follow the instructions.
When the new wallet on NewChain is created, go to "Receive" and copy a "Receiving address".
Use it to send all your coins from newly split wallet to the new one. This is so the UTXO set is totally different including future change addresses etc.
#2 high vs low fee and RBF
You can play it safer and raise the odds of the above method succeeding.
The trick is very simple.
You will have to send the nLocktime transaction on LegacyChain with a high fee and the NewChaintransaction with a very low one. You shall also enable RBF (replace-by-fee) on the second transaction to bump the fee later.
If you include a high enough fee the chances are the first transaction will be confirmed on LegacyChain almost immediately.
The second transaction will very likely be "stuck" for quite some time. When the first transaction has at least 3 confirmations, bump the fee of the second tx significantly.
It will eventually be confirmed on NewChain and your coins will be split.
#3 Honorable mentions
There are few other methods to split coins that are worth mentioning.
The safest method is mixing your coins with coinbase transactions.
Those are transactions that are included in every single minted block and contain mining reward. They only exist within the chain they were minted on so they are invalid on other chains and would be rejected as such.
This method, however, requires you to wait 100 blocks until coinbase transactions can be spent.
Usually, that's around 16 hours but in the event of a chain split it may be significantly longer until mining difficulty readjusts.
Difference in fees
The chances are two chains will differ in block height. Hash rate distribution might be very uneven making one chain confirming transactions faster than the other, therefore fees will also be very different.
Let's say LegacyChain will have relatively cheap fees and NewChain exorbitant ones.
You will want to send a transaction on LegacyChain with a lower fee first. It should not be minted by NewChain miners because they only confirm expensive transactions.
After the first tx is confirmed, make another one on NewChain with a significantly higher fee and wait for miners to pick it up.
This method is very simple but you might wait a while until the market plays its role and creates a wide gap in fees.
Mix with split coins
As the title suggest you may want to look for a mixer that contains already split coins.
Mixing your coins with split coins will make sure it won't be minted on another chain because such transaction would be invalid.
I think there's a big opportunity for miners to create a service for mixing coins with their coinbase transcations.
Differences in protocol rules
Depending on the type of a split, there might be slight differences in protocol rules between two chains.
If that's the case just make a transaction in a way that is valid on one chain and invalid on the other.
For example in the case of a hard fork where one side of the chain accepts 2MB blocks, all you need to do is make a transaction on that chain.
It will be rejected by network participants on 1MB chain because the block size limit is different. When the first transaction confirms, you can then safely spend coins on the other chain too.
I hope there won't be any split in Bitcoin, but if it happens you better be prepared and know how to split your bitcoins.
You may also want to do nothing and wait for the market's reaction.
Because of the very long difficulty-adjustment period, splits may not survive for too long as confirmation times on the shorter chain are significantly slower.
LegacyChain may also be re-organized when NewChain gains the majority of hash rate. It means that all blocks on LegacyChain will be orphaned and nodes will follow the longest chain NewChain. On the other hand, NewChain isn't vulnerable to reorgs.
Without a hard fork to tackle re-org protection, difficulty adjustment etc., chain splits in Bitcoin are possible but (financially) painful and likely to be avoided.
I hope you find this post helpful. Please let me know in the comments section below if you have any questions.
P.S. Feel free to use our UASF BIP148 Electrum server: bitcoin.freedomnode.com:50001