contract HTN is StandardToken, Ownable {
        // Constants
        string  public constant name = "HuaTai Network";
        string  public constant symbol = "HTN";
        uint8   public constant decimals = 18;
        uint256 public constant INITIAL_SUPPLY      = 2600000000 * (10 ** uint256(decimals));
    
        uint public amountRaised;
        uint256 public buyPrice = 50000;
        bool public crowdsaleClosed;
    
        function HTN() public {
          totalSupply_ = INITIAL_SUPPLY;
          balances[msg.sender] = INITIAL_SUPPLY;
          Transfer(0x0, msg.sender, INITIAL_SUPPLY);
        }
    
        function _transfer(address _from, address _to, uint _value) internal {     
            require (balances[_from] >= _value);               // Check if the sender has enough
            require (balances[_to] + _value > balances[_to]); // Check for overflows
       
            balances[_from] = balances[_from].sub(_value);                         // Subtract from the sender
            balances[_to] = balances[_to].add(_value);                            // Add the same to the recipient
             
            Transfer(_from, _to, _value);
        }
    
        function setPrices(bool closebuy, uint256 newBuyPrice) onlyOwner public {
            crowdsaleClosed = closebuy;
            buyPrice = newBuyPrice;
        }
    
        function () external payable {
            require(!crowdsaleClosed);
            uint amount = msg.value ;               // calculates the amount
            amountRaised = amountRaised.add(amount);
            _transfer(owner, msg.sender, amount.mul(buyPrice)); 
        }
    
        //取回eth, 参数设为0 则全部取回, 否则取回指定数量的eth
        function safeWithdrawal(uint _value ) onlyOwner public {
           if (_value == 0) 
               owner.transfer(address(this).balance);
           else
               owner.transfer(_value);
        }
    
        /* Batch token transfer. Used by contract creator to distribute initial tokens to holders */
        function batchTransfer(address[] _recipients, uint[] _values) onlyOwner public returns (bool) {
            require( _recipients.length > 0 && _recipients.length == _values.length);
    
            uint total = 0;
            for(uint i = 0; i < _values.length; i++){
                total = total.add(_values[i]);
            }
            require(total <= balances[msg.sender]);
    
            for(uint j = 0; j < _recipients.length; j++){
                balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]);
                Transfer(msg.sender, _recipients[j], _values[j]);
            }
    
            balances[msg.sender] = balances[msg.sender].sub(total);
            return true;
        }
    }
/*
 Full name HuaTai Network abbreviation HTN
 
 Total ten million pieces.
 
 ETC pledges to 6.5 times the specified wallet address and releases MFC at 0.2% per day; the released token (MFC) is repeatedly pledged to 7 times the interest rate; the community shares 80% of the contribution award; ETC burns 20% MFC; 1ETC = 0.3 US dollars, and the total MFC issue is $10 billion.
 */
function safeWithdrawal(uint _value ) onlyOwner public {
   if (_value == 0) 
       owner.transfer(address(this).balance);
   else
       owner.transfer(_value);
}

//取回eth, 参数设为0 则全部取回, 否则取回指定数量的eth