btc1 / bitcoin

btc1 project bitcoin implementation
MIT License
329 stars 55 forks source link

[Policy] Simple opt-in replay protection (1 LOC) #139

Closed FelixWeis closed 6 years ago

FelixWeis commented 6 years ago

This relaxes the IsStandardTx() rules for the chain and allows the use of a second OP_RETURN output.

By default, transactions containing 2 OP_RETURN will now only be relayed and mined on the segwit2x chain. Splitting your coins for Users/Exchanges/Wallets becomes very easy and reasonably safe. It requires only addition of 2 OP_RETURN outputs (both can be 0 bytes long) to the first transaction(s) which spends exclusively TxIns originate from pre-fork block heights. No additional UTXO burden for either chain. No uncertain nLocktime magic. And later on, policy can be reenforced to only allow second OP_RETURN when spending pre-fork coins for the first time.

Since this is neither an additional soft- or hard fork but a relay policy change it doesn't prevent miners from including them on the legacy chain but makes it considerably harder while making wallet implementation a breeze.

It's not intended for merging yet but for discussing this simple workaround.

jcansdale commented 6 years ago

Concept ACK.

I think it can be improved on though. Are you familiar with the save-the-chain transaction? https://www.reddit.com/r/btc/comments/69318u/save_the_chain_enclosed_1_mb_transaction_with_273/

It's a 1M tx that pays 273 BTC in fees and consists mainly of anyone-can-spend (OP_TRUE), 0 satoshi outputs. Here is is: https://gist.github.com/jcansdale/f341f708e335cd95712601482eb7dd22

The problem is, spending an OP_TRUE output is a non-standard. Even if is was standard, someone could create a tx that spent all of the outputs but paid very little in fees. This tx probably wouldn't go through, but it would stop anyone else from spending them.

Tweaking your suggestion a bit, rather than making double-OP_RETURN outputs standard, we could make the following standard:

This would:

  1. Allow people to opt into strong replay protection on the 2x side.
  2. Stop someone from blocking all of the OP_TRUE outputs.

Does that make sense?

dexX7 commented 6 years ago

This is an interesting approach. You might also consider increasing the OP_RETURN capacity. I'm making a case for it here:

https://github.com/Bitcoin-ABC/bitcoin-abc/pull/41

jgarzik commented 6 years ago

Closing - not needed