Fix nonce issue for replay attack (#692)

* fix nonce issue for replay attack

* fix lint

* add to changelog
This commit is contained in:
Daniel Choi
2021-01-08 22:44:50 -03:00
committed by GitHub
parent 4a619b1e1b
commit d7bdbd7488
3 changed files with 10 additions and 8 deletions
+7 -7
View File
@@ -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")