@@ -196,6 +196,10 @@ type signTransactionResult struct {
196
196
Tx * types.Transaction `json:"tx"`
197
197
}
198
198
199
+ // SignTx sends the transaction to the external signer.
200
+ // If chainID is nil, or tx.ChainID is zero, the chain ID will be assigned
201
+ // by the external signer. For non-legacy transactions, the chain ID of the
202
+ // transaction overrides the chainID parameter.
199
203
func (api * ExternalSigner ) SignTx (account accounts.Account , tx * types.Transaction , chainID * big.Int ) (* types.Transaction , error ) {
200
204
data := hexutil .Bytes (tx .Data ())
201
205
var to * common.MixedcaseAddress
@@ -218,17 +222,17 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
218
222
args .MaxFeePerGas = (* hexutil .Big )(tx .GasFeeCap ())
219
223
args .MaxPriorityFeePerGas = (* hexutil .Big )(tx .GasTipCap ())
220
224
default :
221
- return nil , fmt .Errorf ("Unsupported tx type %d" , tx .Type ())
225
+ return nil , fmt .Errorf ("unsupported tx type %d" , tx .Type ())
222
226
}
223
227
// We should request the default chain id that we're operating with
224
228
// (the chain we're executing on)
225
- if chainID != nil {
229
+ if chainID != nil && chainID . Sign () != 0 {
226
230
args .ChainID = (* hexutil .Big )(chainID )
227
231
}
228
232
if tx .Type () != types .LegacyTxType {
229
233
// However, if the user asked for a particular chain id, then we should
230
234
// use that instead.
231
- if tx .ChainId () != nil {
235
+ if tx .ChainId (). Sign () != 0 {
232
236
args .ChainID = (* hexutil .Big )(tx .ChainId ())
233
237
}
234
238
accessList := tx .AccessList ()
0 commit comments