mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
internal/ethapi: return detail insufficient fund error in EstimateGas
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
30d5d7c1b3
commit
2d253fbdfc
1 changed files with 4 additions and 3 deletions
|
|
@ -1238,10 +1238,11 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
|
|||
balance := state.GetBalance(*args.From) // from can't be nil
|
||||
available := new(big.Int).Set(balance)
|
||||
if args.Value != nil {
|
||||
if args.Value.ToInt().Cmp(available) >= 0 {
|
||||
return 0, core.ErrInsufficientFundsForTransfer
|
||||
value := args.Value.ToInt()
|
||||
if value.Cmp(available) >= 0 {
|
||||
return 0, fmt.Errorf("%v: address: %s, have: %v, want: %v", core.ErrInsufficientFundsForTransfer, *args.From, available, value)
|
||||
}
|
||||
available.Sub(available, args.Value.ToInt())
|
||||
available.Sub(available, value)
|
||||
}
|
||||
allowance := new(big.Int).Div(available, feeCap)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue