Skip to content

Instantly share code, notes, and snippets.

@alexvandesande
Last active July 17, 2016 19:37
Show Gist options
  • Save alexvandesande/ff30d194173b17fe9b25acfd4a2188e3 to your computer and use it in GitHub Desktop.
Save alexvandesande/ff30d194173b17fe9b25acfd4a2188e3 to your computer and use it in GitHub Desktop.
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);
}
}
}
@jph108
Copy link

jph108 commented Jul 15, 2016

This needs to be done before the fork, I take it?

@el33th4x0r
Copy link

@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.

@alexvandesande
Copy link
Author

@el33th4x0r changed it. Always a good eye for bugs!

@veox
Copy link

veox commented Jul 15, 2016

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