Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. contract escrow {
  2. mapping (uint => Holding) public holdings;
  3. uint public numHoldings;
  4. address god;
  5. bool killable = true;
  6.  
  7. struct Holding {
  8. uint amount;
  9. address receiver;
  10. bool unSpent;
  11. Signer[] signers;
  12. }
  13. struct Signer {
  14. address userAddress;
  15. bool hasSigned;
  16. }
  17.  
  18. function escrow(){
  19. god = msg.sender;
  20. }
  21.  
  22. function holdCoin(address _receiver, address[] _signers){
  23. numHoldings++;
  24.  
  25. holdings[numHoldings].amount = msg.value;
  26. holdings[numHoldings].receiver = _receiver;
  27. holdings[numHoldings].unSpent = true;
  28.  
  29. for(uint i = 0; i < _signers.length; i++){
  30. holdings[numHoldings].signers.push(Signer({userAddress: _signers[i], hasSigned: false}));
  31. }
  32. }
  33.  
  34. function signRelease(uint holdingID){
  35. Holding memory holding;
  36. holding = holdings[holdingID];
  37. if(holdings[holdingID].unSpent == true){
  38. bool readyForRelease = true;
  39.  
  40. for(uint i = 0; i <= holding.signers.length; i++){
  41. if(holding.signers[i].userAddress == msg.sender){
  42. holding.signers[i].hasSigned = true;
  43. }
  44. else if(holding.signers[i].hasSigned == false){
  45. readyForRelease = false;
  46. }
  47. }
  48.  
  49. if(readyForRelease){
  50. holdings[holdingID].unSpent = false;
  51. if(holdings[holdingID].receiver.send(holdings[holdingID].amount))
  52. throw;
  53. }
  54. }
  55. }
  56.  
  57. function imortilize(){ if(msg.sender == god){killable = false;}}
  58. function kill(){ if(msg.sender == god && killable )suicide(god);}
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement