Last active
October 19, 2017 15:48
-
-
Save pirapira/e7f5d3d44d5b6b14ca2ad1980083e233 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
// Based on http://www.blunderingcode.com/ether-vaults/ | |
contract Vault(address hotwallet, address vaultKey, address recoveryKey) { | |
case(void unvault(uint256 amount)) { | |
if (sender(msg) != vaultKey) abort; | |
uint256 unvaultPeriod = 60 * 60 * 24 * 7 * 2; // two weeks | |
if (now(block) + unvaultPeriod < now(block)) abort; | |
return then become UnVaulting(now(block) + unvaultPeriod, amount, hotwallet, vaultKey, recoveryKey); | |
} | |
case(void recover(address _newHotWallet)) { | |
if (sender(msg) != recoveryKey) abort; | |
return then become Vault(_newHotWallet, vaultKey, recoveryKey); | |
} | |
case(void destroy()) { | |
if (sender(msg) != recoveryKey) abort; | |
return then become Destroyed(); | |
} | |
} | |
contract UnVaulting(uint256 redeemtime, uint256 amount, address hotwallet, address vaultKey, address recoveryKey) { | |
case(void redeem()) { | |
if (amount > balance(this)) abort; | |
void = hotwallet.default() with amount reentrance { abort; }; | |
return then become Vault(hotwallet, vaultKey, recoveryKey); | |
} | |
case(void recover(address _newHotWallet)) { | |
if (sender(msg) != recoveryKey) abort; | |
return then become Vault(_newHotWallet, vaultKey, recoveryKey); | |
} | |
case(void destroy()) { | |
if (sender(msg) != recoveryKey) abort; | |
return then become Destroyed(); | |
} | |
} | |
contract Destroyed() { | |
// any call just throws; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment