| 55 | } |
| 56 | |
| 57 | func GetAccounts() (result []string, err error) { |
| 58 | path := "" |
| 59 | |
| 60 | switch session.Network { |
| 61 | case NETWORK_MAINNET: |
| 62 | _, err = os.Stat(filepath.Join(AppPath(), "mainnet")) |
| 63 | if err != nil { |
| 64 | return |
| 65 | } else { |
| 66 | path = filepath.Join(AppPath(), "mainnet") + string(filepath.Separator) |
| 67 | } |
| 68 | case NETWORK_SIMULATOR: |
| 69 | _, err = os.Stat(filepath.Join(AppPath(), "testnet_simulator")) |
| 70 | if err != nil { |
| 71 | return |
| 72 | } else { |
| 73 | path = filepath.Join(AppPath(), "testnet_simulator") + string(filepath.Separator) |
| 74 | } |
| 75 | default: |
| 76 | _, err = os.Stat(filepath.Join(AppPath(), "testnet")) |
| 77 | if err != nil { |
| 78 | return |
| 79 | } else { |
| 80 | path = filepath.Join(AppPath(), "testnet") + string(filepath.Separator) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | matches, _ := filepath.Glob(path + "*.db") |
| 85 | result = []string{} |
| 86 | |
| 87 | for _, match := range matches { |
| 88 | check, _ := os.Stat(match) |
| 89 | if !check.IsDir() { |
| 90 | if strings.Contains(match, ".db") { |
| 91 | split := strings.Split(match, string(filepath.Separator)) |
| 92 | pos := len(split) - 1 |
| 93 | match = split[pos] |
| 94 | result = append(result, match) |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | if len(result) == 0 { |
| 101 | // TODO: May do something here like start the user at Create/Restore Account window. |
| 102 | } |
| 103 | */ |
| 104 | |
| 105 | return |
| 106 | } |
| 107 | |
| 108 | func findAccount() (result bool) { |
| 109 | matches, err := filepath.Glob(session.Path) |