Skip to content

Commit 25c3e12

Browse files
committed
keystore: add self key to the listing
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 11a67b8 commit 25c3e12

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

core/commands/keystore.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var KeyGenCmd = &cmds.Command{
4040
Tagline: "Create a new keypair",
4141
},
4242
Options: []cmds.Option{
43-
cmds.StringOption("type", "t", "type of the key to create"),
43+
cmds.StringOption("type", "t", "type of the key to create [rsa, ed25519]"),
4444
cmds.IntOption("size", "s", "size of the key to generate"),
4545
},
4646
Arguments: []cmds.Argument{
@@ -160,7 +160,9 @@ var KeyListCmd = &cmds.Command{
160160

161161
sort.Strings(keys)
162162

163-
list := make([]KeyOutput, 0, len(keys))
163+
list := make([]KeyOutput, 0, len(keys)+1)
164+
165+
list = append(list, KeyOutput{Name: "self", Id: n.Identity.Pretty()})
164166

165167
for _, key := range keys {
166168
privKey, err := n.Repo.Keystore().Get(key)

test/sharness/t0165-keystore.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test_key_cmd() {
2222
test_expect_success "both keys show up in list output" '
2323
echo bazed > list_exp &&
2424
echo foobarsa >> list_exp &&
25+
echo self >> list_exp
2526
ipfs key list | sort > list_out &&
2627
test_cmp list_exp list_out
2728
'
@@ -30,6 +31,10 @@ test_key_cmd() {
3031
ipfs key list -l | grep $edhash > /dev/null &&
3132
ipfs key list -l | grep $rsahash > /dev/null
3233
'
34+
35+
test_expect_success "key list -l contains self key with peerID" '
36+
ipfs key list -l | grep "$(ipfs config Identity.PeerID) self"
37+
'
3338
}
3439

3540
test_key_cmd

0 commit comments

Comments
 (0)