Skip to content

Commit

Permalink
"ipfs key list": include the hash of the key id in addition to the name.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Jan 10, 2017
1 parent c6ce6d3 commit a4aadfd
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion core/commands/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,28 @@ var KeyListCmd = &cmds.Command{
}

sort.Strings(keys)
res.SetOutput(&stringList{keys})

list := make([]string, 0, len(keys))

for _, key := range keys {
privKey, err := n.Repo.Keystore().Get(key)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}

pubKey := privKey.GetPublic()

pid, err := peer.IDFromPublicKey(pubKey)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}

list = append(list, key+" "+pid.Pretty())
}

res.SetOutput(&stringList{list})
},
Marshalers: cmds.MarshalerMap{
cmds.Text: stringListMarshaler,
Expand Down

0 comments on commit a4aadfd

Please sign in to comment.