contract ReservedValue is Ownable {
  using SafeMath for uint;
  event Income(address source, uint256 amount);

  address payable public wallet;
  //total reserved eth amount
  uint256 public totalReserved;

  constructor(address payable _w) public {
    require(_w != address(0));
    wallet = _w;

  }

  function setWallet(address payable _w) external onlyOwner {
    require(address(_w) != address(0));
    wallet = _w;
  }

  /// @notice The fallback function payable
  function() external payable {
    require(msg.value > 0);
    _flushBalance();
  }

  function _flushBalance() internal {
    uint256 balance = address(this).balance.sub(totalReserved);
    if (balance > 0) {
      address(wallet).transfer(balance);
      emit Income(address(this), balance);
    }
  }

  function _incTotalReserved(uint value) internal {
    totalReserved = totalReserved.add(value);
  }

  function _decTotalReserved(uint value) internal {
    totalReserved = totalReserved.sub(value);
  }
}
function() external payable {
    require(msg.value > 0);
    _flushBalance();
  }
/// @notice The fallback function payable