Merge pull request #585 from filecoin-project/fix/wallet-import-file

fix wallet import from a file
This commit is contained in:
Whyrusleeping 2019-11-13 05:08:01 +09:00 committed by GitHub
commit 266e37ba18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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