From 80e0a8631496f63ec349666278d66b98fc134537 Mon Sep 17 00:00:00 2001 From: Philemon Ukane Date: Tue, 10 Sep 2024 18:08:26 +0100 Subject: [PATCH] handle dex mnemonic seedq display Signed-off-by: Philemon Ukane --- ui/page/settings/app_settings_page.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ui/page/settings/app_settings_page.go b/ui/page/settings/app_settings_page.go index ac60f0022..b3b067ac6 100644 --- a/ui/page/settings/app_settings_page.go +++ b/ui/page/settings/app_settings_page.go @@ -763,17 +763,21 @@ func (pg *AppSettingsPage) showDEXSeedModal() { } func formatDEXSeedAsString(seed dex.Bytes) string { - chunkRegex := regexp.MustCompile(`.{1,32}`) - chunks := chunkRegex.FindAllString(seed.String(), -1) + if len(seed) == 128 { // 64 bytes, 128 hex character legacy seed + chunkRegex := regexp.MustCompile(`.{1,32}`) + chunks := chunkRegex.FindAllString(seed.String(), -1) + + var seedChunks []string + subChunkRegex := regexp.MustCompile(`.{1,8}`) + for _, chunk := range chunks { + subChunks := subChunkRegex.FindAllString(chunk, -1) + seedChunks = append(seedChunks, strings.Join(subChunks, " ")) + } - var seedChunks []string - subChunkRegex := regexp.MustCompile(`.{1,8}`) - for _, chunk := range chunks { - subChunks := subChunkRegex.FindAllString(chunk, -1) - seedChunks = append(seedChunks, strings.Join(subChunks, " ")) + return strings.Join(seedChunks, "\n") + } else { + return seed.String() } - - return strings.Join(seedChunks, "\n") } func ChangeNetworkType(load *load.Load, windowNav app.WindowNavigator, newNetType string) {