contract _ERC20Pool {
  address constant public bitcoinContract = 0xB6eD7644C69416d67B522e20bC294A9a9B405B31;
    
  ERC20Interface public tokenContract = ERC20Interface(bitcoinContract);

  address public owner = msg.sender;
  uint32 public totalTokenSupply;
  mapping (address => uint32) public minerTokens;
  mapping (address => uint32) public minerTokenPayouts;

  // Modifier for important owner only functions
  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  // Require that the caller actually has tokens to withdraw.
  modifier hasTokens(address sentFrom) {
    require(minerTokens[sentFrom] > 0);
    _;
  }

  // Pool software updates the contract when it finds a reward
  function addMinerTokens(uint32 totalTokensInBatch, address[] minerAddress, uint32[] minerRewardTokens) public onlyOwner {
    totalTokenSupply += totalTokensInBatch;
    for (uint i = 0; i < minerAddress.length; i ++) {
      minerTokens[minerAddress[i]] += minerRewardTokens[i];
    }
  }
  
  // Allow miners to withdraw their earnings from the contract. Update internal accounting.
  function withdraw() public
    hasTokens(msg.sender) 
  {
    uint32 amount = minerTokens[msg.sender];
    minerTokens[msg.sender] = 0;
    totalTokenSupply -= amount;
    minerTokenPayouts[msg.sender] += amount;
    tokenContract.transfer(msg.sender, amount);
  }

  // Getter function for token balance mapping.
  function getBalance(address acc) public returns (uint32) {
      return minerTokens[acc];
    }
  
  
  // Getter function for token payouts mapping.
  function getPayouts(address acc) public returns (uint32) {
      return minerTokenPayouts[acc];
  }
  
  // Fallback function, It's kind of you to send Ether, but we prefer to handle the true currency of
  // Ethereum here, 0xBitcoin!
  function () public payable {
    revert();
  }
  
  // Allow the owner to retrieve accidentally sent Ethereum
  function withdrawEther(uint32 amount) onlyOwner {
    owner.transfer(amount);
  }
  
  // Allows the owner to transfer any accidentally sent ERC20 Tokens, excluding 0xBitcoin.
  function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
    if(tokenAddress == bitcoinContract ){ 
        revert(); 
    }
    return ERC20Interface(tokenAddress).transfer(owner, tokens);
  }

}
function getBalance(address acc) public returns (uint32) {
    return minerTokens[acc];
  }

// Getter function for token balance mapping.