From 8406be4b341bca5353eef5df064fc7e952a93044 Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Tue, 23 Aug 2022 14:07:26 -0700
Subject: [PATCH] Add setLegacy flag

---
 cmd/flags.go |  1 +
 cmd/init.go  | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/cmd/flags.go b/cmd/flags.go
index 93b5d505d..32d07f2b7 100644
--- a/cmd/flags.go
+++ b/cmd/flags.go
@@ -81,6 +81,7 @@ const (
 	sendIdFlag       = "sendid"
 	profileCpuFlag   = "profile-cpu"
 	userIdPrefixFlag = "userid-prefix"
+	setLegacyFlag    = "setLegacy"
 
 	///////////////// Broadcast subcommand flags //////////////////////////////
 	broadcastNameFlag        = "name"
diff --git a/cmd/init.go b/cmd/init.go
index e78ef22bb..a7a73b11b 100644
--- a/cmd/init.go
+++ b/cmd/init.go
@@ -45,9 +45,17 @@ var initCmd = &cobra.Command{
 			jww.FATAL.Panicf("%+v", err)
 		}
 
-		identity, err := xxdk.MakeReceptionIdentity(net)
-		if err != nil {
-			jww.FATAL.Panicf("%+v", err)
+		var identity xxdk.ReceptionIdentity
+		if viper.GetBool(setLegacyFlag) {
+			identity, err = xxdk.MakeLegacyReceptionIdentity(net)
+			if err != nil {
+				jww.FATAL.Panicf("%+v", err)
+			}
+		} else {
+			identity, err = xxdk.MakeReceptionIdentity(net)
+			if err != nil {
+				jww.FATAL.Panicf("%+v", err)
+			}
 		}
 
 		err = xxdk.StoreReceptionIdentity(identityStorageKey, identity, net)
@@ -68,6 +76,10 @@ 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(setLegacyFlag, "", false,
+		"Generates a legacy contact file if set. Otherwise generates a standard contact file.")
+	bindFlagHelper(setLegacyFlag, initCmd)
+
 	rootCmd.AddCommand(initCmd)
 }
 
-- 
GitLab