|
|
@ -23,9 +23,9 @@ contract Shareable { |
|
|
|
uint public required; |
|
|
|
uint public required; |
|
|
|
|
|
|
|
|
|
|
|
// list of owners |
|
|
|
// list of owners |
|
|
|
uint[256] owners; |
|
|
|
address[256] owners; |
|
|
|
// index on the list of owners to allow reverse lookup |
|
|
|
// index on the list of owners to allow reverse lookup |
|
|
|
mapping(uint => uint) ownerIndex; |
|
|
|
mapping(address => uint) ownerIndex; |
|
|
|
// the ongoing operations. |
|
|
|
// the ongoing operations. |
|
|
|
mapping(bytes32 => PendingState) pendings; |
|
|
|
mapping(bytes32 => PendingState) pendings; |
|
|
|
bytes32[] pendingsIndex; |
|
|
|
bytes32[] pendingsIndex; |
|
|
@ -57,18 +57,18 @@ contract Shareable { |
|
|
|
// constructor is given number of sigs required to do protected "onlymanyowners" transactions |
|
|
|
// constructor is given number of sigs required to do protected "onlymanyowners" transactions |
|
|
|
// as well as the selection of addresses capable of confirming them. |
|
|
|
// as well as the selection of addresses capable of confirming them. |
|
|
|
function Shareable(address[] _owners, uint _required) { |
|
|
|
function Shareable(address[] _owners, uint _required) { |
|
|
|
owners[1] = uint(msg.sender); |
|
|
|
owners[1] = msg.sender; |
|
|
|
ownerIndex[uint(msg.sender)] = 1; |
|
|
|
ownerIndex[msg.sender] = 1; |
|
|
|
for (uint i = 0; i < _owners.length; ++i) { |
|
|
|
for (uint i = 0; i < _owners.length; ++i) { |
|
|
|
owners[2 + i] = uint(_owners[i]); |
|
|
|
owners[2 + i] = _owners[i]; |
|
|
|
ownerIndex[uint(_owners[i])] = 2 + i; |
|
|
|
ownerIndex[_owners[i]] = 2 + i; |
|
|
|
} |
|
|
|
} |
|
|
|
required = _required; |
|
|
|
required = _required; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Revokes a prior confirmation of the given operation |
|
|
|
// Revokes a prior confirmation of the given operation |
|
|
|
function revoke(bytes32 _operation) external { |
|
|
|
function revoke(bytes32 _operation) external { |
|
|
|
uint index = ownerIndex[uint(msg.sender)]; |
|
|
|
uint index = ownerIndex[msg.sender]; |
|
|
|
// make sure they're an owner |
|
|
|
// make sure they're an owner |
|
|
|
if (index == 0) { |
|
|
|
if (index == 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -88,12 +88,12 @@ contract Shareable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isOwner(address _addr) constant returns (bool) { |
|
|
|
function isOwner(address _addr) constant returns (bool) { |
|
|
|
return ownerIndex[uint(_addr)] > 0; |
|
|
|
return ownerIndex[_addr] > 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) { |
|
|
|
function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) { |
|
|
|
var pending = pendings[_operation]; |
|
|
|
var pending = pendings[_operation]; |
|
|
|
uint index = ownerIndex[uint(_owner)]; |
|
|
|
uint index = ownerIndex[_owner]; |
|
|
|
|
|
|
|
|
|
|
|
// make sure they're an owner |
|
|
|
// make sure they're an owner |
|
|
|
if (index == 0) { |
|
|
|
if (index == 0) { |
|
|
@ -107,7 +107,7 @@ contract Shareable { |
|
|
|
|
|
|
|
|
|
|
|
function confirmAndCheck(bytes32 _operation) internal returns (bool) { |
|
|
|
function confirmAndCheck(bytes32 _operation) internal returns (bool) { |
|
|
|
// determine what index the present sender is: |
|
|
|
// determine what index the present sender is: |
|
|
|
uint index = ownerIndex[uint(msg.sender)]; |
|
|
|
uint index = ownerIndex[msg.sender]; |
|
|
|
// make sure they're an owner |
|
|
|
// make sure they're an owner |
|
|
|
if (index == 0) { |
|
|
|
if (index == 0) { |
|
|
|
return; |
|
|
|
return; |
|
|
|