@@ -268,27 +268,34 @@ func Transition(ctx *cli.Context) error {
268
268
// txWithKey is a helper-struct, to allow us to use the types.Transaction along with
269
269
// a `secretKey`-field, for input
270
270
type txWithKey struct {
271
- key * ecdsa.PrivateKey
272
- tx * types.Transaction
271
+ key * ecdsa.PrivateKey
272
+ tx * types.Transaction
273
+ protected bool
273
274
}
274
275
275
276
func (t * txWithKey ) UnmarshalJSON (input []byte ) error {
276
- // Read the secretKey, if present
277
- type sKey struct {
278
- Key * common.Hash `json:"secretKey"`
277
+ // Read the metadata, if present
278
+ type txMetadata struct {
279
+ Key * common.Hash `json:"secretKey"`
280
+ Protected * bool `json:"protected"`
279
281
}
280
- var key sKey
281
- if err := json .Unmarshal (input , & key ); err != nil {
282
+ var data txMetadata
283
+ if err := json .Unmarshal (input , & data ); err != nil {
282
284
return err
283
285
}
284
- if key .Key != nil {
285
- k := key .Key .Hex ()[2 :]
286
+ if data .Key != nil {
287
+ k := data .Key .Hex ()[2 :]
286
288
if ecdsaKey , err := crypto .HexToECDSA (k ); err != nil {
287
289
return err
288
290
} else {
289
291
t .key = ecdsaKey
290
292
}
291
293
}
294
+ if data .Protected != nil {
295
+ t .protected = * data .Protected
296
+ } else {
297
+ t .protected = true
298
+ }
292
299
// Now, read the transaction itself
293
300
var tx types.Transaction
294
301
if err := json .Unmarshal (input , & tx ); err != nil {
@@ -317,7 +324,15 @@ func signUnsignedTransactions(txs []*txWithKey, signer types.Signer) (types.Tran
317
324
v , r , s := tx .RawSignatureValues ()
318
325
if key != nil && v .BitLen ()+ r .BitLen ()+ s .BitLen () == 0 {
319
326
// This transaction needs to be signed
320
- signed , err := types .SignTx (tx , signer , key )
327
+ var (
328
+ signed * types.Transaction
329
+ err error
330
+ )
331
+ if txWithKey .protected {
332
+ signed , err = types .SignTx (tx , signer , key )
333
+ } else {
334
+ signed , err = types .SignTx (tx , types.FrontierSigner {}, key )
335
+ }
321
336
if err != nil {
322
337
return nil , NewError (ErrorJson , fmt .Errorf ("tx %d: failed to sign tx: %v" , i , err ))
323
338
}
0 commit comments