@ -477,7 +477,7 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args Transactio
if args . Nonce == nil {
return nil , fmt . Errorf ( "nonce not specified" )
}
// Before actually sign the transaction, ensure the transaction fee is reasonable.
// Before actually signing the transaction, ensure the transaction fee is reasonable.
tx := args . toTransaction ( )
if err := checkTxFee ( tx . GasPrice ( ) , tx . Gas ( ) , s . b . RPCTxFeeCap ( ) ) ; err != nil {
return nil , err
@ -1008,8 +1008,19 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
}
hi = block . GasLimit ( )
}
// Normalize the max fee per gas the call is willing to spend.
var feeCap * big . Int
if args . GasPrice != nil && ( args . MaxFeePerGas != nil || args . MaxPriorityFeePerGas != nil ) {
return 0 , errors . New ( "both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified" )
} else if args . GasPrice != nil {
feeCap = args . GasPrice . ToInt ( )
} else if args . MaxFeePerGas != nil {
feeCap = args . MaxFeePerGas . ToInt ( )
} else {
feeCap = common . Big0
}
// Recap the highest gas limit with account's available balance.
if args . GasPrice != nil && args . GasPrice . ToInt ( ) . BitLen ( ) != 0 {
if feeCap . BitLen ( ) != 0 {
state , _ , err := b . StateAndHeaderByNumberOrHash ( ctx , blockNrOrHash )
if err != nil {
return 0 , err
@ -1022,7 +1033,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
}
available . Sub ( available , args . Value . ToInt ( ) )
}
allowance := new ( big . Int ) . Div ( available , args . GasPrice . ToInt ( ) )
allowance := new ( big . Int ) . Div ( available , feeCap )
// If the allowance is larger than maximum uint64, skip checking
if allowance . IsUint64 ( ) && hi > allowance . Uint64 ( ) {
@ -1031,7 +1042,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
transfer = new ( hexutil . Big )
}
log . Warn ( "Gas estimation capped by limited funds" , "original" , hi , "balance" , balance ,
"sent" , transfer . ToInt ( ) , "gasprice" , args . GasPrice . ToInt ( ) , "fundable" , allowance )
"sent" , transfer . ToInt ( ) , "maxFeePerGas" , feeCap , "fundable" , allowance )
hi = allowance . Uint64 ( )
}
}