func generateAddrs(c *gcli.Context) error { // get number of address that are need to be generated. num := c.Uint("n") if num == 0 { return errors.New("-n must > 0") } jsonFmt := c.Bool("json") w := c.String("f") if !strings.HasSuffix(w, walletExt) { return errWalletName } // only wallet file name, no path. if filepath.Base(w) == w { w = filepath.Join(cfg.WalletDir, w) } wlt, err := wallet.Load(w) if err != nil { errorWithHelp(c, err) return nil } addrs := wlt.GenerateAddresses(int(num)) dir, err := filepath.Abs(filepath.Dir(w)) if err != nil { return err } if err := wlt.Save(dir); err != nil { return errors.New("save wallet failed") } s, err := addrResult(addrs, jsonFmt) if err != nil { return err } fmt.Println(s) return nil }