not display privatekey
This commit is contained in:
parent
a2431ff70a
commit
2cf19d41af
@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"golang.org/x/term"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
@ -327,13 +328,21 @@ var walletImport = &cli.Command{
|
||||
|
||||
var inpdata []byte
|
||||
if !cctx.Args().Present() || cctx.Args().First() == "-" {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
fmt.Print("Enter private key: ")
|
||||
indata, err := reader.ReadBytes('\n')
|
||||
if err != nil {
|
||||
return err
|
||||
if term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
fmt.Print("Enter private key(not display in the terminal): ")
|
||||
inpdata, err = term.ReadPassword(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println()
|
||||
} else {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
indata, err := reader.ReadBytes('\n')
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inpdata = indata
|
||||
}
|
||||
inpdata = indata
|
||||
|
||||
} else {
|
||||
fdata, err := os.ReadFile(cctx.Args().First())
|
||||
|
2
go.mod
2
go.mod
@ -155,6 +155,7 @@ require (
|
||||
golang.org/x/net v0.10.0
|
||||
golang.org/x/sync v0.2.0
|
||||
golang.org/x/sys v0.9.0
|
||||
golang.org/x/term v0.9.0
|
||||
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9
|
||||
golang.org/x/tools v0.9.1
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
|
||||
@ -322,7 +323,6 @@ require (
|
||||
go.uber.org/dig v1.17.0 // indirect
|
||||
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
|
||||
golang.org/x/mod v0.10.0 // indirect
|
||||
golang.org/x/term v0.9.0 // indirect
|
||||
golang.org/x/text v0.10.0 // indirect
|
||||
gonum.org/v1/gonum v0.13.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
|
||||
|
Loading…
Reference in New Issue
Block a user