func accountCreate(ctx *cli.Context) { am := utils.GetAccountManager(ctx) passphrase := getPassPhrase(ctx, "Your new account is locked with a password. Please give a password. Do not forget this password.", true) acct, err := am.NewAccount(passphrase) if err != nil { utils.Fatalf("Could not create the account: %v", err) } fmt.Printf("Address: %x\n", acct) }
func accountList(ctx *cli.Context) { am := utils.GetAccountManager(ctx) accts, err := am.Accounts() if err != nil { utils.Fatalf("Could not list accounts: %v", err) } name := "Primary" for i, acct := range accts { fmt.Printf("%s #%d: %x\n", name, i, acct) name = "Account" } }
func accountImport(ctx *cli.Context) { keyfile := ctx.Args().First() if len(keyfile) == 0 { utils.Fatalf("keyfile must be given as argument") } am := utils.GetAccountManager(ctx) passphrase := getPassPhrase(ctx, "Your new account is locked with a password. Please give a password. Do not forget this password.", true) acct, err := am.Import(keyfile, passphrase) if err != nil { utils.Fatalf("Could not create the account: %v", err) } fmt.Printf("Address: %x\n", acct) }
func importWallet(ctx *cli.Context) { keyfile := ctx.Args().First() if len(keyfile) == 0 { utils.Fatalf("keyfile must be given as argument") } keyJson, err := ioutil.ReadFile(keyfile) if err != nil { utils.Fatalf("Could not read wallet file: %v", err) } am := utils.GetAccountManager(ctx) passphrase := getPassPhrase(ctx, "", false) acct, err := am.ImportPreSaleKey(keyJson, passphrase) if err != nil { utils.Fatalf("Could not create the account: %v", err) } fmt.Printf("Address: %x\n", acct) }