Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- contract escrow {
- mapping (uint => Holding) public holdings;
- uint public numHoldings;
- address god;
- bool killable = true;
- struct Holding {
- uint amount;
- address receiver;
- bool unSpent;
- Signer[] signers;
- }
- struct Signer {
- address userAddress;
- bool hasSigned;
- }
- function escrow(){
- god = msg.sender;
- }
- function holdCoin(address _receiver, address[] _signers){
- numHoldings++;
- holdings[numHoldings].amount = msg.value;
- holdings[numHoldings].receiver = _receiver;
- holdings[numHoldings].unSpent = true;
- for(uint i = 0; i < _signers.length; i++){
- holdings[numHoldings].signers.push(Signer({userAddress: _signers[i], hasSigned: false}));
- }
- }
- function signRelease(uint holdingID){
- Holding memory holding;
- holding = holdings[holdingID];
- if(holdings[holdingID].unSpent == true){
- bool readyForRelease = true;
- for(uint i = 0; i <= holding.signers.length; i++){
- if(holding.signers[i].userAddress == msg.sender){
- holding.signers[i].hasSigned = true;
- }
- else if(holding.signers[i].hasSigned == false){
- readyForRelease = false;
- }
- }
- if(readyForRelease){
- holdings[holdingID].unSpent = false;
- if(holdings[holdingID].receiver.send(holdings[holdingID].amount))
- throw;
- }
- }
- }
- function imortilize(){ if(msg.sender == god){killable = false;}}
- function kill(){ if(msg.sender == god && killable )suicide(god);}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement