@@ -268,27 +268,34 @@ func Transition(ctx *cli.Context) error {
268268// txWithKey is a helper-struct, to allow us to use the types.Transaction along with
269269// a `secretKey`-field, for input
270270type txWithKey struct {
271- key * ecdsa.PrivateKey
272- tx * types.Transaction
271+ key * ecdsa.PrivateKey
272+ tx * types.Transaction
273+ protected bool
273274}
274275
275276func (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"`
279281 }
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 {
282284 return err
283285 }
284- if key .Key != nil {
285- k := key .Key .Hex ()[2 :]
286+ if data .Key != nil {
287+ k := data .Key .Hex ()[2 :]
286288 if ecdsaKey , err := crypto .HexToECDSA (k ); err != nil {
287289 return err
288290 } else {
289291 t .key = ecdsaKey
290292 }
291293 }
294+ if data .Protected != nil {
295+ t .protected = * data .Protected
296+ } else {
297+ t .protected = true
298+ }
292299 // Now, read the transaction itself
293300 var tx types.Transaction
294301 if err := json .Unmarshal (input , & tx ); err != nil {
@@ -317,7 +324,15 @@ func signUnsignedTransactions(txs []*txWithKey, signer types.Signer) (types.Tran
317324 v , r , s := tx .RawSignatureValues ()
318325 if key != nil && v .BitLen ()+ r .BitLen ()+ s .BitLen () == 0 {
319326 // 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+ }
321336 if err != nil {
322337 return nil , NewError (ErrorJson , fmt .Errorf ("tx %d: failed to sign tx: %v" , i , err ))
323338 }
0 commit comments