Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Extend key-gen output #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (

func viewEvent(opts docopt.Opts) {
verbose, _ := opts.Bool("--verbose")
jsonformat, _ := opts.Bool("--json")
jsonformat, _ := opts.Bool("--json")
id := opts["<id>"].(string)
if id == "" {
log.Println("provided event ID was empty")
return
}
initNostr()

_, all := pool.Sub(nostr.Filters{{IDs: []string{id}}})
_, all, unsubscribe := pool.Sub(nostr.Filters{{IDs: []string{id}}})
for event := range nostr.Unique(all) {
if event.ID != id {
log.Printf("got unexpected event %s.\n", event.ID)
Expand All @@ -28,6 +28,7 @@ func viewEvent(opts docopt.Opts) {
printEvent(event, nil, verbose, jsonformat)
break
}
unsubscribe()
}

func deleteEvent(opts docopt.Opts) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/dustin/go-humanize v1.0.0
github.com/mitchellh/go-homedir v1.1.0
github.com/nbd-wtf/go-nostr v0.9.0
github.com/nbd-wtf/go-nostr v0.10.0
gopkg.in/yaml.v2 v2.3.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/nbd-wtf/go-nostr v0.9.0 h1:6wDsgKUXOtnzHwe/RW80yBebsVNg5jbRyBCTyxlDjiw=
github.com/nbd-wtf/go-nostr v0.9.0/go.mod h1:qFFTIxh15H5GGN0WsBI/P73DteqsevnhSEW/yk8nEf4=
github.com/nbd-wtf/go-nostr v0.10.0 h1:95y0VjyplDCInPn7VD2eNvRHwTGib1LxfVKp0Fv2ZQY=
github.com/nbd-wtf/go-nostr v0.10.0/go.mod h1:qFFTIxh15H5GGN0WsBI/P73DteqsevnhSEW/yk8nEf4=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
3 changes: 2 additions & 1 deletion home.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func home(opts docopt.Opts, inboxMode bool) {
filters[0].Until = &untilTime
}
filters[0].Kinds = intkinds
_, all := pool.Sub(filters)
_, all, unsubscribe := pool.Sub(filters)
for event := range nostr.Unique(all) {
// Do we have a nick for the author of this message?
nick, ok := nameMap[event.PubKey]
Expand Down Expand Up @@ -105,4 +105,5 @@ func home(opts docopt.Opts, inboxMode bool) {

printEvent(event, &nick, verbose, jsonformat)
}
unsubscribe()
}
11 changes: 10 additions & 1 deletion key.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func showPublicKey(opts docopt.Opts) {
if pubkey != "" {
fmt.Printf("%s\n", pubkey)

nip19pubkey, _ := nip19.EncodePublicKey(pubkey, "")
nip19pubkey, _ := nip19.EncodePublicKey(pubkey)
fmt.Printf("%s\n", nip19pubkey)
}
}
Expand Down Expand Up @@ -86,6 +86,15 @@ func keyGen(opts docopt.Opts) {
return
}

pk := getPubKey(sk)
nsec, _ := nip19.EncodePrivateKey(sk)
npub, _ := nip19.EncodePublicKey(pk)
nprofile, _ := nip19.EncodeProfile(pk, []string{})

fmt.Println("seed:", seedWords)
fmt.Println("private key:", sk)
fmt.Println("public key:", pk)
fmt.Println("nsec:", nsec)
fmt.Println("npub:", npub)
fmt.Println("nprofile:", nprofile)
}
13 changes: 7 additions & 6 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ import (

func showProfile(opts docopt.Opts) {
verbose, _ := opts.Bool("--verbose")
jsonformat, _ := opts.Bool("--json")
key := nip19.TranslatePublicKey(opts["<pubkey>"].(string))
jsonformat, _ := opts.Bool("--json")
key, _ := nip19.EncodeProfile(opts["<pubkey>"].(string), []string{})
if key == "" {
log.Println("Profile key is empty! Exiting.")
return
}

initNostr()

_, all := pool.Sub(nostr.Filters{{Authors: []string{key}, Kinds: []int{0}}})
_, all, unsubscribe := pool.Sub(nostr.Filters{{Authors: []string{key}, Kinds: []int{0}}})
for event := range nostr.Unique(all) {
printEvent(event, nil, verbose, jsonformat)
}
unsubscribe()
}

func follow(opts docopt.Opts) {
key := nip19.TranslatePublicKey(opts["<pubkey>"].(string))
key, _ := nip19.EncodeProfile(opts["<pubkey>"].(string), []string{})
if key == "" {
log.Println("Follow key is empty! Exiting.")
return
Expand All @@ -38,15 +39,15 @@ func follow(opts docopt.Opts) {
name = ""
}

config.Following[key] = Follow{
config.Following[key] = Follow{
Key: key,
Name: name,
}
fmt.Printf("Followed %s.\n", key)
}

func unfollow(opts docopt.Opts) {
key := nip19.TranslatePublicKey(opts["<pubkey>"].(string))
key, _ := nip19.EncodeProfile(opts["<pubkey>"].(string), []string{})
if key == "" {
log.Println("No unfollow key provided! Exiting.")
return
Expand Down