|
|
@ -448,14 +448,15 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args Transactio |
|
|
|
if args.Gas == nil { |
|
|
|
if args.Gas == nil { |
|
|
|
return nil, fmt.Errorf("gas not specified") |
|
|
|
return nil, fmt.Errorf("gas not specified") |
|
|
|
} |
|
|
|
} |
|
|
|
if args.GasPrice == nil { |
|
|
|
if args.GasPrice == nil && (args.MaxFeePerGas == nil || args.MaxPriorityFeePerGas == nil) { |
|
|
|
return nil, fmt.Errorf("gasPrice not specified") |
|
|
|
return nil, fmt.Errorf("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") |
|
|
|
} |
|
|
|
} |
|
|
|
if args.Nonce == nil { |
|
|
|
if args.Nonce == nil { |
|
|
|
return nil, fmt.Errorf("nonce not specified") |
|
|
|
return nil, fmt.Errorf("nonce not specified") |
|
|
|
} |
|
|
|
} |
|
|
|
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
|
|
|
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
|
|
|
if err := checkTxFee(args.GasPrice.ToInt(), uint64(*args.Gas), s.b.RPCTxFeeCap()); err != nil { |
|
|
|
tx := args.toTransaction() |
|
|
|
|
|
|
|
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
signed, err := s.signTransaction(ctx, &args, passwd) |
|
|
|
signed, err := s.signTransaction(ctx, &args, passwd) |
|
|
@ -1697,8 +1698,9 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Tra |
|
|
|
return SubmitTransaction(ctx, s.b, signed) |
|
|
|
return SubmitTransaction(ctx, s.b, signed) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// FillTransaction fills the defaults (nonce, gas, gasPrice) on a given unsigned transaction,
|
|
|
|
// FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields)
|
|
|
|
// and returns it to the caller for further processing (signing + broadcast)
|
|
|
|
// on a given unsigned transaction, and returns it to the caller for further
|
|
|
|
|
|
|
|
// processing (signing + broadcast).
|
|
|
|
func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) { |
|
|
|
func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) { |
|
|
|
// Set some sanity defaults and terminate on failure
|
|
|
|
// Set some sanity defaults and terminate on failure
|
|
|
|
if err := args.setDefaults(ctx, s.b); err != nil { |
|
|
|
if err := args.setDefaults(ctx, s.b); err != nil { |
|
|
@ -1761,8 +1763,8 @@ func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args Tra |
|
|
|
if args.Gas == nil { |
|
|
|
if args.Gas == nil { |
|
|
|
return nil, fmt.Errorf("gas not specified") |
|
|
|
return nil, fmt.Errorf("gas not specified") |
|
|
|
} |
|
|
|
} |
|
|
|
if args.GasPrice == nil { |
|
|
|
if args.GasPrice == nil && (args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil) { |
|
|
|
return nil, fmt.Errorf("gasPrice not specified") |
|
|
|
return nil, fmt.Errorf("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") |
|
|
|
} |
|
|
|
} |
|
|
|
if args.Nonce == nil { |
|
|
|
if args.Nonce == nil { |
|
|
|
return nil, fmt.Errorf("nonce not specified") |
|
|
|
return nil, fmt.Errorf("nonce not specified") |
|
|
@ -1771,18 +1773,19 @@ func (s *PublicTransactionPoolAPI) SignTransaction(ctx context.Context, args Tra |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
|
|
|
// Before actually sign the transaction, ensure the transaction fee is reasonable.
|
|
|
|
if err := checkTxFee(args.GasPrice.ToInt(), uint64(*args.Gas), s.b.RPCTxFeeCap()); err != nil { |
|
|
|
tx := args.toTransaction() |
|
|
|
|
|
|
|
if err := checkTxFee(tx.GasPrice(), tx.Gas(), s.b.RPCTxFeeCap()); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
tx, err := s.sign(args.from(), args.toTransaction()) |
|
|
|
signed, err := s.sign(args.from(), tx) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
data, err := tx.MarshalBinary() |
|
|
|
data, err := signed.MarshalBinary() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
return &SignTransactionResult{data, tx}, nil |
|
|
|
return &SignTransactionResult{data, signed}, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// PendingTransactions returns the transactions that are in the transaction pool
|
|
|
|
// PendingTransactions returns the transactions that are in the transaction pool
|
|
|
|