Closed gundas closed 7 years ago
You need equal or greater balance as the sending amount with fee. I don't see any problem there. You mean like this:
if( fee ) {
(_success, _fee) = getTransactionFee(amount);
require( _success );
if ( db.balanceOf(from) == amount ) {
_amount = safeSub(amount, _fee);
}
}
require( db.balanceOf(from) >= safeAdd(_amount, _fee) );
I agree. Thus, my question is why the code additionally handles a special case when balance == amount
, but not the case when balance
is greater than amount
but lower than amount + fee
If the address owner want to send her/his balance to an another address, then the fee is subtracted from the sending amount. If we don't have this, the users can not empty an address. :)
So, if I want to transfer amount=100 COR and the fee=5 COR, then:
yes, this is correct. I dont think that schould be weird. This IF is only when the sender want send all of his/her balance. If the balance is 1514717841 ION then he/she need to send 1514717841 ION. If he/she send1514717840 ION would be failed.
The code works as intended - so, I am closing this issue.
token.sol
on rc branch:_transfer(...)
function handles the cases whenbalanceOf(from) == amount
by decreasing theamount
by_fee
. However, it does not handle the case whenamount < balanceOf(from) < amount + fee
- it simply fails the require check:Looks kind of inconsistent to me.