I was trying to add another branch of OP_ELSE to mimic Gmaxwell's CoinSwap but I don't really know how to skip the previous OP_ELSE and run the next OP_ELSE. Do you know how to do it?
I think I remember reading that you can nest the OP_IFs - in which case you would do something like this:
OP_IF
OP_IF
...
OP_ELSE
...
OP_ENDIF
OP_ELSE
...
OP_ENDIF
Hi, many thanks for the clue. I managed to construct the following structure
OP_IF
OP_IF
OP_DUP OP_SHA256 OP_EQUAL
OP_DROP
OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
OP_ELSE
OP_NOP2 OP_DROP
OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
OP_ENDIF
OP_ELSE
2 2 OP_CHECKMULTISIG
OP_ENDIF
The structure probably is the first few steps of Gmaxwell's Coinswap. I am not sure whether this can be called as atomic. Basically the tx can be redemed by 3 different ways:
- secret value + sig2
- sig1 + pubkey1 after certain CLTV
- sig1 + sig2 (in 2-of-2 multisig)