Last active
July 17, 2016 19:37
-
-
Save alexvandesande/ff30d194173b17fe9b25acfd4a2188e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract ethExchange { | |
| address public public ethClassicWithdrawer; | |
| address public public ethForkWithdrawer; | |
| bool public accepted; | |
| address public refundContract = '0xbf4ed7b27f1d666546e30d74d50d173d20bca754'; | |
| function ethExchange(uint amountToExchange) { | |
| ethClassicWithdrawer = msg.sender; | |
| } | |
| function acceptExchange() { | |
| if (msg.value < this.balance || accepted) throw; | |
| ethForkWithdrawer = msg.sender; | |
| accepted = true; | |
| } | |
| function withdraw() { | |
| if (block.number < 1920000) throw; | |
| if (!accepted || refundContract.balance < 1000000 ether) { | |
| selfDestruct(ethClassicWithdrawer); | |
| } else { | |
| selfDestruct(ethForkWithdrawer); | |
| } | |
| } | |
| } |
@LaurentMT pointed out, rightfully, that acceptExchange() needs to check that accepted is false (i.e. no counterparty has been established), or else the ethForkWithdrawer can be overwritten at any time.
@el33th4x0r changed it. Always a good eye for bugs!
Duh, wait. That's the constructor, LOL, disregard what's below.
ethClassicWithdrawer is not guarded in ethExchange(). Anyone can get the full balance of the contract as long as no counterparty has been estabilished, on either tine.
To do this, after block 1920000, call ethExchange(<anything>), then immediately withdraw().
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This needs to be done before the fork, I take it?