I am new to Ethereum and I deployed a contract in Ganache which has a function like this:
function withdraw(uint256 amount) public payable returns(bool) {
require(accounts[msg.sender].balance >= amount);
accounts[msg.sender].balance -= amount;
bool r = msg.sender.send(amount);
if (!r){
accounts[msg.sender].balance += amount;
}
return r;
}
Then, I use Truffle console to send transactions calling function withdraw.
I expected there should be two transactions: one is calling function withdraw and another is the contract sending ether to the sender, which is a result of msg.sender.send(amount).
But I only got one transaction in Ganache which about calling function withdraw.
Am I understanding <address>.send() wrong?