From 2472f62ba0f9c082d5b7a06320c2af24ace64ffa Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 12 Nov 2019 12:00:40 -0800 Subject: [PATCH] fix wallet import from a file --- cli/wallet.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/wallet.go b/cli/wallet.go index a268056b9..dcd5f55d2 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -201,24 +201,24 @@ var walletImport = &cli.Command{ defer closer() ctx := ReqContext(cctx) - var data []byte + var hexdata []byte if !cctx.Args().Present() || cctx.Args().First() == "-" { indata, err := ioutil.ReadAll(os.Stdin) if err != nil { return err } - dec, err := hex.DecodeString(strings.TrimSpace(string(indata))) - if err != nil { - return err - } + hexdata = indata - data = dec } else { fdata, err := ioutil.ReadFile(cctx.Args().First()) if err != nil { return err } - data = fdata + hexdata = fdata + } + data, err := hex.DecodeString(strings.TrimSpace(string(hexdata))) + if err != nil { + return err } var ki types.KeyInfo