forked from cerc-io/laconicd-deprecated
Fix nonce issue for replay attack (#692)
* fix nonce issue for replay attack * fix lint * add to changelog
This commit is contained in:
@@ -1000,16 +1000,16 @@ func (api *PublicEthereumAPI) generateFromArgs(args rpctypes.SendTxArgs) (*evmty
|
||||
gasPrice = big.NewInt(ethermint.DefaultGasPrice)
|
||||
}
|
||||
|
||||
if args.Nonce == nil {
|
||||
// get the nonce from the account retriever and the pending transactions
|
||||
nonce, err = api.accountNonce(api.clientCtx, args.From, true)
|
||||
} else {
|
||||
nonce = (uint64)(*args.Nonce)
|
||||
}
|
||||
|
||||
// get the nonce from the account retriever and the pending transactions
|
||||
nonce, err = api.accountNonce(api.clientCtx, args.From, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if args.Nonce != nil {
|
||||
if nonce != (uint64)(*args.Nonce) {
|
||||
return nil, fmt.Errorf(fmt.Sprintf("invalid nonce; got %d, expected %d", (uint64)(*args.Nonce), nonce))
|
||||
}
|
||||
}
|
||||
|
||||
if args.Data != nil && args.Input != nil && !bytes.Equal(*args.Data, *args.Input) {
|
||||
return nil, errors.New("both 'data' and 'input' are set and not equal. Please use 'input' to pass transaction call data")
|
||||
|
||||
Reference in New Issue
Block a user