diff --git a/VERSION b/VERSION index a771be0c9..c2956c316 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.171.13 +0.171.14 diff --git a/services/wallet/transfer/transaction.go b/services/wallet/transfer/transaction.go index 0617d1cb9..ab3cea93e 100644 --- a/services/wallet/transfer/transaction.go +++ b/services/wallet/transfer/transaction.go @@ -400,9 +400,11 @@ func (tm *TransactionManager) ProceedWithTransactionsSignatures(ctx context.Cont hashes := make(map[uint64][]types.Hash) for _, desc := range tm.transactionsForKeycardSingning { hash, err := tm.transactor.SendBuiltTransactionWithSignature(desc.chainID, desc.builtTx, desc.signature) - defer func() { - desc.unlock(err == nil, desc.builtTx.Nonce()) - }() + if desc.unlock != nil { + defer func() { + desc.unlock(err == nil, desc.builtTx.Nonce()) + }() + } if err != nil { return nil, err } diff --git a/transactions/nonce.go b/transactions/nonce.go index 7d7314492..f54da49cd 100644 --- a/transactions/nonce.go +++ b/transactions/nonce.go @@ -25,6 +25,10 @@ func NewNonce() *Nonce { func (n *Nonce) Next(rpcWrapper *rpcWrapper, from types.Address) (uint64, UnlockNonceFunc, error) { n.addrLock.LockAddr(from) current, err := n.GetCurrent(rpcWrapper, from) + if err != nil { + return 0, nil, err + } + unlock := func(inc bool, nonce uint64) { if inc { if _, ok := n.localNonce[rpcWrapper.chainID]; !ok { @@ -36,7 +40,7 @@ func (n *Nonce) Next(rpcWrapper *rpcWrapper, from types.Address) (uint64, Unlock n.addrLock.UnlockAddr(from) } - return current, unlock, err + return current, unlock, nil } func (n *Nonce) GetCurrent(rpcWrapper *rpcWrapper, from types.Address) (uint64, error) { diff --git a/transactions/transactor.go b/transactions/transactor.go index 6eb9745e8..bed0bf681 100644 --- a/transactions/transactor.go +++ b/transactions/transactor.go @@ -157,9 +157,11 @@ func (t *Transactor) SendTransactionWithSignature(chainID uint64, args SendTxArg if err != nil { return hash, err } - defer func() { - unlock(err == nil, expectedNonce) - }() + if unlock != nil { + defer func() { + unlock(err == nil, expectedNonce) + }() + } if tx.Nonce() != expectedNonce { return hash, &ErrBadNonce{tx.Nonce(), expectedNonce} @@ -179,7 +181,9 @@ func (t *Transactor) HashTransaction(args SendTxArgs) (validatedArgs SendTxArgs, if err != nil { return validatedArgs, hash, err } - defer unlock(false, 0) + if unlock != nil { + defer unlock(false, 0) + } gasPrice := (*big.Int)(args.GasPrice) gasFeeCap := (*big.Int)(args.MaxFeePerGas) @@ -273,13 +277,16 @@ func (t *Transactor) validateAndBuildTransaction(rpcWrapper *rpcWrapper, args Se return tx, nil, ErrInvalidSendTxArgs } - nonce, unlock, err := t.nonce.Next(rpcWrapper, args.From) - if err != nil { - return tx, nil, err - } + var nonce uint64 if args.Nonce != nil { nonce = uint64(*args.Nonce) + } else { + nonce, unlock, err = t.nonce.Next(rpcWrapper, args.From) + if err != nil { + return tx, nil, err + } } + ctx, cancel := context.WithTimeout(context.Background(), t.rpcCallTimeout) defer cancel()