diff --git a/cmd/flags.go b/cmd/flags.go index 096c92d792b002457173a69c27aff68042e5ad63..edd40259a56eb227c267811c125ffab746ec0f67 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -82,6 +82,7 @@ const ( profileCpuFlag = "profile-cpu" profileMemFlag = "profile-mem" userIdPrefixFlag = "userid-prefix" + legacyFlag = "legacy" ///////////////// Broadcast subcommand flags ////////////////////////////// broadcastNameFlag = "name" diff --git a/cmd/init.go b/cmd/init.go index e78ef22bb78387d64210e9d7365bc76fa765fd94..00294f2c4a79d6bd38ce9c330df5b86466a608c3 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -45,16 +45,27 @@ var initCmd = &cobra.Command{ jww.FATAL.Panicf("%+v", err) } - identity, err := xxdk.MakeReceptionIdentity(net) + // Generate identity + var identity xxdk.ReceptionIdentity + if viper.GetBool(legacyFlag) { + identity, err = xxdk.MakeLegacyReceptionIdentity(net) + } else { + identity, err = xxdk.MakeReceptionIdentity(net) + + } + + // Panic if conditional branch fails if err != nil { jww.FATAL.Panicf("%+v", err) } + // Store identity err = xxdk.StoreReceptionIdentity(identityStorageKey, identity, net) if err != nil { jww.FATAL.Panicf("%+v", err) } + // Write contact to file jww.INFO.Printf("User: %s", identity.ID) writeContact(identity.GetContact()) @@ -68,6 +79,11 @@ func init() { "Desired prefix of userID to brute force when running init command. Prepend (?i) for case-insensitive. Only Base64 characters are valid.") bindFlagHelper(userIdPrefixFlag, initCmd) + initCmd.Flags().BoolP(legacyFlag, "", false, + "Generates a legacy identity if set. "+ + "If this flag is absent, a standard identity will be generated.") + bindFlagHelper(legacyFlag, initCmd) + rootCmd.AddCommand(initCmd) }