Skip to content

Commit

Permalink
use if else for master key
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Apr 3, 2024
1 parent cea3ec6 commit d640297
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions cmd/thor/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,31 +396,32 @@ func masterKeyPath(ctx *cli.Context) (string, error) {

func loadNodeMaster(ctx *cli.Context) (*node.Master, error) {

var key *ecdsa.PrivateKey
var err error

masterKey := ctx.String(masterKeyFlag.Name)
if masterKey != "" {
key, err := crypto.HexToECDSA(masterKey)
key, err = crypto.HexToECDSA(masterKey)
if err != nil {
return nil, errors.Wrap(err, "failed to convert master key")
}
master := &node.Master{PrivateKey: key}
if master.Beneficiary, err = beneficiary(ctx); err != nil {
} else {
path, err := masterKeyPath(ctx)
if err != nil {
return nil, err
}
return master, nil
key, err = loadOrGeneratePrivateKey(path)
if err != nil {
return nil, errors.Wrap(err, "load or generate master key")
}
}

path, err := masterKeyPath(ctx)
if err != nil {
return nil, err
}
key, err := loadOrGeneratePrivateKey(path)
if err != nil {
return nil, errors.Wrap(err, "load or generate master key")
}
master := &node.Master{PrivateKey: key}

if master.Beneficiary, err = beneficiary(ctx); err != nil {
return nil, err
}

return master, nil
}

Expand Down

0 comments on commit d640297

Please sign in to comment.