I am transferring ownership to a new address. After changing ownership, I wanted to move all funds to the new address. Writing the function like the following is correct ? I have used ```
_transfer(_owner,newOwner,balanceOf(_owner));
statement inside transferOwnership method.
contract Ownable is Context, ERC20 {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () public {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_transfer(_owner,newOwner,balanceOf(_owner));
_owner = newOwner;
}
}