diff --git a/event.go b/event.go index 37c9c4e..8aa0255 100644 --- a/event.go +++ b/event.go @@ -142,7 +142,7 @@ example: kindWasSupplied := false mustRehashAndResign := false if stdinEvent != "" { - if err := json.Unmarshal([]byte(stdinEvent), &evt); err != nil { + if err := easyjson.Unmarshal([]byte(stdinEvent), &evt); err != nil { lineProcessingError(c, "invalid event received from stdin: %s", err) continue } @@ -235,7 +235,7 @@ example: } else { var result string if c.Bool("envelope") { - j, _ := json.Marshal([]any{"EVENT", evt}) + j, _ := json.Marshal(nostr.EventEnvelope{Event: evt}) result = string(j) } else if c.Bool("nson") { result, _ = nson.Marshal(&evt) diff --git a/req.go b/req.go index 8d8d3a3..d4ac174 100644 --- a/req.go +++ b/req.go @@ -6,6 +6,7 @@ import ( "os" "strings" + "github.com/mailru/easyjson" "github.com/nbd-wtf/go-nostr" "github.com/urfave/cli/v2" ) @@ -113,7 +114,7 @@ example: for stdinFilter := range getStdinLinesOrBlank() { filter := nostr.Filter{} if stdinFilter != "" { - if err := json.Unmarshal([]byte(stdinFilter), &filter); err != nil { + if err := easyjson.Unmarshal([]byte(stdinFilter), &filter); err != nil { lineProcessingError(c, "invalid filter '%s' received from stdin: %s", stdinFilter, err) continue } @@ -184,7 +185,7 @@ example: if c.Bool("bare") { result = filter.String() } else { - j, _ := json.Marshal([]any{"REQ", "nak", filter}) + j, _ := json.Marshal(nostr.ReqEnvelope{SubscriptionID: "nak", Filters: nostr.Filters{filter}}) result = string(j) }