|
|
|
@ -478,16 +478,16 @@ func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args Transacti |
|
|
|
|
// No need to obtain the noncelock mutex, since we won't be sending this
|
|
|
|
|
// tx into the transaction pool, but right back to the user
|
|
|
|
|
if args.From == nil { |
|
|
|
|
return nil, fmt.Errorf("sender not specified") |
|
|
|
|
return nil, errors.New("sender not specified") |
|
|
|
|
} |
|
|
|
|
if args.Gas == nil { |
|
|
|
|
return nil, fmt.Errorf("gas not specified") |
|
|
|
|
return nil, errors.New("gas not specified") |
|
|
|
|
} |
|
|
|
|
if args.GasPrice == nil && (args.MaxFeePerGas == nil || args.MaxPriorityFeePerGas == nil) { |
|
|
|
|
return nil, fmt.Errorf("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") |
|
|
|
|
return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") |
|
|
|
|
} |
|
|
|
|
if args.Nonce == nil { |
|
|
|
|
return nil, fmt.Errorf("nonce not specified") |
|
|
|
|
return nil, errors.New("nonce not specified") |
|
|
|
|
} |
|
|
|
|
// Before actually signing the transaction, ensure the transaction fee is reasonable.
|
|
|
|
|
tx := args.toTransaction() |
|
|
|
@ -548,7 +548,7 @@ func (s *PersonalAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.By |
|
|
|
|
return common.Address{}, fmt.Errorf("signature must be %d bytes long", crypto.SignatureLength) |
|
|
|
|
} |
|
|
|
|
if sig[crypto.RecoveryIDOffset] != 27 && sig[crypto.RecoveryIDOffset] != 28 { |
|
|
|
|
return common.Address{}, fmt.Errorf("invalid Ethereum signature (V is not 27 or 28)") |
|
|
|
|
return common.Address{}, errors.New("invalid Ethereum signature (V is not 27 or 28)") |
|
|
|
|
} |
|
|
|
|
sig[crypto.RecoveryIDOffset] -= 27 // Transform yellow paper V from 27/28 to 0/1
|
|
|
|
|
|
|
|
|
@ -582,7 +582,7 @@ func (s *PersonalAccountAPI) InitializeWallet(ctx context.Context, url string) ( |
|
|
|
|
case *scwallet.Wallet: |
|
|
|
|
return mnemonic, wallet.Initialize(seed) |
|
|
|
|
default: |
|
|
|
|
return "", fmt.Errorf("specified wallet does not support initialization") |
|
|
|
|
return "", errors.New("specified wallet does not support initialization") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -597,7 +597,7 @@ func (s *PersonalAccountAPI) Unpair(ctx context.Context, url string, pin string) |
|
|
|
|
case *scwallet.Wallet: |
|
|
|
|
return wallet.Unpair([]byte(pin)) |
|
|
|
|
default: |
|
|
|
|
return fmt.Errorf("specified wallet does not support pairing") |
|
|
|
|
return errors.New("specified wallet does not support pairing") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -722,10 +722,10 @@ func decodeHash(s string) (common.Hash, error) { |
|
|
|
|
} |
|
|
|
|
b, err := hex.DecodeString(s) |
|
|
|
|
if err != nil { |
|
|
|
|
return common.Hash{}, fmt.Errorf("hex string invalid") |
|
|
|
|
return common.Hash{}, errors.New("hex string invalid") |
|
|
|
|
} |
|
|
|
|
if len(b) > 32 { |
|
|
|
|
return common.Hash{}, fmt.Errorf("hex string too long, want at most 32 bytes") |
|
|
|
|
return common.Hash{}, errors.New("hex string too long, want at most 32 bytes") |
|
|
|
|
} |
|
|
|
|
return common.BytesToHash(b), nil |
|
|
|
|
} |
|
|
|
@ -1833,13 +1833,13 @@ type SignTransactionResult struct { |
|
|
|
|
// the given from address and it needs to be unlocked.
|
|
|
|
|
func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) { |
|
|
|
|
if args.Gas == nil { |
|
|
|
|
return nil, fmt.Errorf("gas not specified") |
|
|
|
|
return nil, errors.New("gas not specified") |
|
|
|
|
} |
|
|
|
|
if args.GasPrice == nil && (args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil) { |
|
|
|
|
return nil, fmt.Errorf("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") |
|
|
|
|
return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") |
|
|
|
|
} |
|
|
|
|
if args.Nonce == nil { |
|
|
|
|
return nil, fmt.Errorf("nonce not specified") |
|
|
|
|
return nil, errors.New("nonce not specified") |
|
|
|
|
} |
|
|
|
|
if err := args.setDefaults(ctx, s.b); err != nil { |
|
|
|
|
return nil, err |
|
|
|
@ -1888,7 +1888,7 @@ func (s *TransactionAPI) PendingTransactions() ([]*RPCTransaction, error) { |
|
|
|
|
// the given transaction from the pool and reinsert it with the new gas price and limit.
|
|
|
|
|
func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { |
|
|
|
|
if sendArgs.Nonce == nil { |
|
|
|
|
return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec") |
|
|
|
|
return common.Hash{}, errors.New("missing transaction nonce in transaction spec") |
|
|
|
|
} |
|
|
|
|
if err := sendArgs.setDefaults(ctx, s.b); err != nil { |
|
|
|
|
return common.Hash{}, err |
|
|
|
|