forked from TrueCloudLab/neoneo-go
cli: refactor readAccountInfo method
It doesn't require binwriter.
This commit is contained in:
parent
2daae43eaf
commit
a348347fe8
1 changed files with 7 additions and 7 deletions
|
@ -318,7 +318,7 @@ func addAccount(ctx *cli.Context) error {
|
||||||
|
|
||||||
defer wall.Close()
|
defer wall.Close()
|
||||||
|
|
||||||
if err := createAccount(ctx, wall); err != nil {
|
if err := createAccount(wall); err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ func createWallet(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Bool("account") {
|
if ctx.Bool("account") {
|
||||||
if err := createAccount(ctx, wall); err != nil {
|
if err := createAccount(wall); err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -646,7 +646,7 @@ func createWallet(ctx *cli.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func readAccountInfo(w io.Writer) (string, string, error) {
|
func readAccountInfo() (string, string, error) {
|
||||||
rawName, _ := input.ReadLine("Enter the name of the account > ")
|
rawName, _ := input.ReadLine("Enter the name of the account > ")
|
||||||
phrase, err := input.ReadPassword("Enter passphrase > ")
|
phrase, err := input.ReadPassword("Enter passphrase > ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -661,12 +661,12 @@ func readAccountInfo(w io.Writer) (string, string, error) {
|
||||||
return "", "", errPhraseMismatch
|
return "", "", errPhraseMismatch
|
||||||
}
|
}
|
||||||
|
|
||||||
name := strings.TrimRight(string(rawName), "\n")
|
name := strings.TrimRight(rawName, "\n")
|
||||||
return name, phrase, nil
|
return name, phrase, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAccount(ctx *cli.Context, wall *wallet.Wallet) error {
|
func createAccount(wall *wallet.Wallet) error {
|
||||||
name, phrase, err := readAccountInfo(ctx.App.Writer)
|
name, phrase, err := readAccountInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -698,7 +698,7 @@ func newAccountFromWIF(w io.Writer, wif string) (*wallet.Account, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(w, "Provided WIF was unencrypted. Wallet can contain only encrypted keys.")
|
fmt.Fprintln(w, "Provided WIF was unencrypted. Wallet can contain only encrypted keys.")
|
||||||
name, pass, err := readAccountInfo(w)
|
name, pass, err := readAccountInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue