func main() { url := flag.String("url", "", "base_url:port") num := flag.Int("num", 0, "# of users(orbids)") amount := flag.Float64("amount", 0.0, "# of charge amount per user") flag.Parse() if *url == "" { flag.Usage() return } dir, err := os.Getwd() if err != nil { fmt.Println(err) return } f, err := os.Create(dir + "/orbids.txt") if err != nil { fmt.Println(err) return } defer f.Close() var orbIds []string for i := 0; i < *num; i++ { client := orb.NewClient(*url, nil) id := &orb.NewID{} id, err := client.Generate(strconv.Itoa(i)) if err != nil { fmt.Println(strconv.Itoa(i) + " [failed] " + err.Error()) } else { fmt.Println("Generated " + strconv.Itoa(i) + " : " + id.OrbId + " (" + strconv.FormatBool(id.Existed) + ")") orbIds = append(orbIds, id.OrbId) f.WriteString(id.OrbId + "\n") } } for _, v := range orbIds { client := orb.NewClient(*url, nil) p := &orb.Purchase{} p, err := client.Purchase(v, *amount, 0.0) if err != nil { fmt.Println("[failed] " + err.Error()) } else { fmt.Printf("Purchased %f coins. %s \n", *amount, p.TxId) } } }
func main() { url := flag.String("url", "", "base_url:port") orbId := flag.String("orbid", "", "orb ID") flag.Parse() if *url == "" || *orbId == "" { flag.Usage() return } client := orb.NewClient(*url, nil) b := &orb.Balance{} b, err := client.GetBalance(*orbId, 0) if err != nil { fmt.Println(err) } fmt.Println(b) }
func main() { url := flag.String("url", "", "base_url:port") from := flag.String("from", "", "FROM orb ID") to := flag.String("to", "", "TO orb ID") amount := flag.Float64("amount", 0.0, "amount of coins to pay") flag.Parse() if *url == "" || *from == "" || *to == "" { flag.Usage() return } client := orb.NewClient(*url, nil) _, err := client.Pay(*from, *to, *amount, 0.0) if err != nil { fmt.Println(err) } }
func main() { url := flag.String("url", "", "base_url:port") orbId := flag.String("orbid", "", "orb ID") amount := flag.Float64("amount", 0.0, "amount of coins to pay") flag.Parse() if *url == "" || *orbId == "" { flag.Usage() return } client := orb.NewClient(*url, nil) p := &orb.Purchase{} p, err := client.Purchase(*orbId, *amount, 0.0) if err != nil { fmt.Println(err) } fmt.Println(p) }