@@ -18,6 +18,7 @@ package ethsigner
18
18
19
19
import (
20
20
"encoding/json"
21
+ "fmt"
21
22
"math/big"
22
23
23
24
"github.com/hyperledger/firefly-signer/pkg/ethtypes"
@@ -97,6 +98,9 @@ func (t *Transaction) Build1559(chainID int64) rlp.List {
97
98
// - By default use EIP-155 signing
98
99
// Never picks legacy-legacy (non EIP-155), or EIP-2930
99
100
func (t * Transaction ) Sign (signer secp256k1.Signer , chainID int64 ) ([]byte , error ) {
101
+ if signer == nil {
102
+ return nil , fmt .Errorf ("invalid signer" )
103
+ }
100
104
if t .MaxPriorityFeePerGas .BigInt ().Sign () > 0 || t .MaxFeePerGas .BigInt ().Sign () > 0 {
101
105
return t .SignEIP1559 (signer , chainID )
102
106
}
@@ -125,6 +129,9 @@ func (t *Transaction) SignaturePayloadLegacyOriginal() *TransactionSignaturePayl
125
129
126
130
// SignLegacyOriginal uses legacy transaction structure, with legacy V value (27/28)
127
131
func (t * Transaction ) SignLegacyOriginal (signer secp256k1.Signer ) ([]byte , error ) {
132
+ if signer == nil {
133
+ return nil , fmt .Errorf ("invalid signer" )
134
+ }
128
135
signatureData := t .SignaturePayloadLegacyOriginal ()
129
136
sig , err := signer .Sign (signatureData .data )
130
137
if err != nil {
@@ -149,6 +156,9 @@ func (t *Transaction) SignaturePayloadLegacyEIP155(chainID int64) *TransactionSi
149
156
150
157
// SignLegacyEIP155 uses legacy transaction structure, with EIP-155 signing V value (2*ChainID + 35 + Y-parity)
151
158
func (t * Transaction ) SignLegacyEIP155 (signer secp256k1.Signer , chainID int64 ) ([]byte , error ) {
159
+ if signer == nil {
160
+ return nil , fmt .Errorf ("invalid signer" )
161
+ }
152
162
153
163
signaturePayload := t .SignaturePayloadLegacyEIP155 (chainID )
154
164
@@ -179,6 +189,9 @@ func (t *Transaction) SignaturePayloadEIP1559(chainID int64) *TransactionSignatu
179
189
180
190
// SignEIP1559 uses EIP-1559 transaction structure (with EIP-2718 transaction type byte), with EIP-2930 V value (0 / 1 - direct parity-Y)
181
191
func (t * Transaction ) SignEIP1559 (signer secp256k1.Signer , chainID int64 ) ([]byte , error ) {
192
+ if signer == nil {
193
+ return nil , fmt .Errorf ("invalid signer" )
194
+ }
182
195
183
196
signaturePayload := t .SignaturePayloadEIP1559 (chainID )
184
197
sig , err := signer .Sign (signaturePayload .data )
0 commit comments