cmd, eth, internal, les: add txfee cap (#21212)
* cmd, eth, internal, les: add gasprice cap * cmd/utils, eth: add default value for gasprice cap * all: use txfee cap * cmd, eth: add fix * cmd, internal: address comments
This commit is contained in:
@ -1520,6 +1520,13 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
|
||||
|
||||
// SubmitTransaction is a helper function that submits tx to txPool and logs a message.
|
||||
func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error) {
|
||||
// If the transaction fee cap is already specified, ensure the
|
||||
// fee of the given transaction is _reasonable_.
|
||||
feeEth := new(big.Float).Quo(new(big.Float).SetInt(new(big.Int).Mul(tx.GasPrice(), new(big.Int).SetUint64(tx.Gas()))), new(big.Float).SetInt(big.NewInt(params.Ether)))
|
||||
feeFloat, _ := feeEth.Float64()
|
||||
if b.RPCTxFeeCap() != 0 && feeFloat > b.RPCTxFeeCap() {
|
||||
return common.Hash{}, fmt.Errorf("tx fee (%.2f ether) exceeds the configured cap (%.2f ether)", feeFloat, b.RPCTxFeeCap())
|
||||
}
|
||||
if err := b.SendTx(ctx, tx); err != nil {
|
||||
return common.Hash{}, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user