From 9f9f00b7a267a17812f39f3a949c2b650f2066b6 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Tue, 10 Aug 2021 11:48:11 +0300 Subject: [PATCH] Adjust HashTransaction to eip1559 This commit fixed eip1559 tx signing on keycard. --- VERSION | 2 +- transactions/transactor.go | 36 +++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 4eb884705..ff6b6b95e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.83.6 +0.83.7 diff --git a/transactions/transactor.go b/transactions/transactor.go index 2b898b241..e5208a3a6 100644 --- a/transactions/transactor.go +++ b/transactions/transactor.go @@ -155,7 +155,9 @@ func (t *Transactor) HashTransaction(args SendTxArgs) (validatedArgs SendTxArgs, } gasPrice := (*big.Int)(args.GasPrice) - if args.GasPrice == nil { + gasFeeCap := (*big.Int)(args.MaxFeePerGas) + gasTipCap := (*big.Int)(args.MaxPriorityFeePerGas) + if args.GasPrice == nil && args.MaxFeePerGas == nil { ctx, cancel := context.WithTimeout(context.Background(), t.rpcCallTimeout) defer cancel() gasPrice, err = t.gasCalculator.SuggestGasPrice(ctx) @@ -180,13 +182,24 @@ func (t *Transactor) HashTransaction(args SendTxArgs) (validatedArgs SendTxArgs, gethTo = common.Address(*args.To) gethToPtr = &gethTo } - gas, err = t.gasCalculator.EstimateGas(ctx, ethereum.CallMsg{ - From: common.Address(args.From), - To: gethToPtr, - GasPrice: gasPrice, - Value: value, - Data: args.GetInput(), - }) + if args.GasPrice == nil { + gas, err = t.gasCalculator.EstimateGas(ctx, ethereum.CallMsg{ + From: common.Address(args.From), + To: gethToPtr, + GasFeeCap: gasFeeCap, + GasTipCap: gasTipCap, + Value: value, + Data: args.GetInput(), + }) + } else { + gas, err = t.gasCalculator.EstimateGas(ctx, ethereum.CallMsg{ + From: common.Address(args.From), + To: gethToPtr, + GasPrice: gasPrice, + Value: value, + Data: args.GetInput(), + }) + } if err != nil { return validatedArgs, hash, err } @@ -201,7 +214,12 @@ func (t *Transactor) HashTransaction(args SendTxArgs) (validatedArgs SendTxArgs, newNonce := hexutil.Uint64(nonce) newGas := hexutil.Uint64(gas) validatedArgs.Nonce = &newNonce - validatedArgs.GasPrice = (*hexutil.Big)(gasPrice) + if args.GasPrice != nil { + validatedArgs.GasPrice = (*hexutil.Big)(gasPrice) + } else { + validatedArgs.MaxPriorityFeePerGas = (*hexutil.Big)(gasTipCap) + validatedArgs.MaxPriorityFeePerGas = (*hexutil.Big)(gasFeeCap) + } validatedArgs.Gas = &newGas tx := t.buildTransaction(validatedArgs)