(c *cli.Context)
| 106 | } |
| 107 | |
| 108 | func actionStart(c *cli.Context) (err error) { |
| 109 | password := "" |
| 110 | // check if there is an account |
| 111 | n := onchain.NumOfAccounts(dosPath) |
| 112 | if n == 0 { |
| 113 | password, err = createWallet() |
| 114 | if err != nil { |
| 115 | fmt.Println("CreateWallet Error : ", err) |
| 116 | return |
| 117 | } |
| 118 | } else { |
| 119 | // check if password is in env variable |
| 120 | password = os.Getenv("PASSPHRASE") |
| 121 | if len(password) == 0 { |
| 122 | password = getPassword("Enter Password: ") |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | key, err := onchain.ReadEthKey(dosPath, password) |
| 127 | if err != nil { |
| 128 | fmt.Println("ReadEthKey Error : ", err) |
| 129 | return |
| 130 | } |
| 131 | log.Init(key.Address.Bytes()[:]) |
| 132 | |
| 133 | //Read Configuration |
| 134 | config := &configuration.Config{} |
| 135 | if err := config.LoadConfig(); err != nil { |
| 136 | fmt.Println("LoadConfig Error : ", err) |
| 137 | return err |
| 138 | } |
| 139 | //Check if config has all information |
| 140 | if len(config.ChainNodePool) == 0 { |
| 141 | fmt.Println("Please provides geth ws address in config.json") |
| 142 | return nil |
| 143 | } |
| 144 | |
| 145 | hasWsAddr := false |
| 146 | for _, gethAddr := range config.ChainNodePool { |
| 147 | if strings.Contains(gethAddr, "ws://") || |
| 148 | strings.Contains(gethAddr, "wss://") { |
| 149 | hasWsAddr = true |
| 150 | break |
| 151 | } |
| 152 | |
| 153 | } |
| 154 | if !hasWsAddr { |
| 155 | fmt.Println("Please provides at least one geth ws address in config.json") |
| 156 | return nil |
| 157 | } |
| 158 | |
| 159 | //fErr, err := os.OpenFile(logFile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666) |
| 160 | //if err != nil { |
| 161 | // fmt.Println("OpenLogFile err ", err) |
| 162 | // return err |
| 163 | //} |
| 164 | //if config.VERSION != Version { |
| 165 | // fmt.Println("config version ", config.VERSION, " not match with binary version ", Version) |
nothing calls this directly
no test coverage detected