I am trying to understand the following contract sample:
// Refund contract for trust DAO #16
contract DAO {
function balanceOf(address addr) returns (uint);
function transferFrom(address from, address to, uint balance) returns (bool);
uint public totalSupply;
}
contract WithdrawDAO {
DAO constant public mainDAO = DAO(0x200450f06520bdd6c527622a273333384d870efb);
address public trustee = 0x7c81d252d9d1295058cd3620835f37e0eedd8840;
function withdraw(){
uint balance = mainDAO.balanceOf(msg.sender);
if (!mainDAO.transferFrom(msg.sender, this, balance) || !msg.sender.send(balance))
throw;
}
function trusteeWithdraw() {
trustee.send((this.balance + mainDAO.balanceOf(this)) - mainDAO.totalSupply());
}
}
I am a bit confused about the withdraw
function. What if the first transfer transferFrom
always failed due to certain reason? Would it somehow lock the fund and therefore the second fund transfer can never happen? Thanks a lot!