Skip to content

Commit

Permalink
fix crash when verify seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Apr 25, 2024
1 parent 82c67a3 commit 3ec91e8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
3 changes: 0 additions & 3 deletions libwallet/assets/wallet/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package wallet

import (
"fmt"
"time"

"github.com/asdine/storm"
Expand Down Expand Up @@ -441,10 +440,8 @@ func (s WordSeedType) ToInt() int {
func (s WordSeedType) AllSeeds() []string {
switch s {
case WordSeed24, WordSeed12:
fmt.Println("-------BIP39WordList--------")
return wordlist.BIP39WordList()
case WordSeed33:
fmt.Println("--------PGPWordList-------")
return wordlist.PGPWordList()
default:
return []string{}
Expand Down
8 changes: 3 additions & 5 deletions ui/page/seedbackup/verify_seed.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package seedbackup

import (
"fmt"
"math/rand"
"strings"

Expand Down Expand Up @@ -97,8 +96,8 @@ func (pg *VerifySeedPage) OnNavigatedTo() {
seedWords := strings.Split(pg.seed, " ")
for _, word := range seedWords {
listGroupSeed = append(listGroupSeed, &layout.List{Axis: layout.Horizontal})
index := seedPosition(strings.TrimSpace(word), allSeeds)
shuffledSeed := pg.getMultiSeed(index, allSeeds) // using allSeeds here modifies the slice
index := seedPosition(word, allSeeds)
shuffledSeed := pg.getMultiSeed(index, pg.wordSeedType.AllSeeds()) // using allSeeds here modifies the slice
multiSeedList = append(multiSeedList, shuffledSeed)
}

Expand Down Expand Up @@ -141,11 +140,10 @@ func (pg *VerifySeedPage) getMultiSeed(realSeedIndex int, allSeeds []string) shu

func seedPosition(seed string, allSeeds []string) int {
for i := range allSeeds {
if strings.TrimSpace(allSeeds[i]) == strings.TrimSpace(seed) {
if allSeeds[i] == seed {
return i
}
}
fmt.Println("NOT FOUND====>", seed)
return -1
}

Expand Down

0 comments on commit 3ec91e8

Please sign in to comment.