I modified the example crowd sale contract from the Ethereum site slightly. First I sent 0.5 ETH from a wallet, it then sent the new tokens and I ran the safeWithdrawal function as the Beneficiary. This then triggered the contract to send the 0.5 ETH to the Beneficiary. I then later sent 1 ETH to the contract and it sent the tokens. I then ran the safeWithdrawal function again as the Beneficiary on the contract but for some reason this time it did not send the 1 ETH. Does it have anything to do with the "if (beneficiary.send(amountRaised))" that it is wrapped in, what is that part even doing?
function safeWithdrawal() {
if (beneficiary == msg.sender) {
if (beneficiary.send(amountRaised)) {
FundTransfer(beneficiary, amountRaised, false);
} else {
//If we fail to send the funds to beneficiary, unlock funders balance
fundingGoalReached = false;
}
}
}
I think I know the problem, amountRaised increases each time, where I have withdraw .5 ETH it never took this off the amountRaised. So now there is 1 ETH but it is trying to withdraw 1.5 ETH. I guess I'm never going to get that back then?
amountRaised
? That not being reset can lead to the contract trying to send a larger amount than it has.