Skip to content

Commit

Permalink
--nevent flag on nak event to print an nevent at the end.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Jan 25, 2024
1 parent 14b69f3 commit 3dfcec6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/mailru/easyjson"
"github.com/nbd-wtf/go-nostr"
"github.com/nbd-wtf/go-nostr/nip19"
"github.com/nbd-wtf/go-nostr/nson"
"github.com/urfave/cli/v2"
"golang.org/x/exp/slices"
Expand Down Expand Up @@ -51,6 +52,10 @@ example:
Name: "auth",
Usage: "always perform NIP-42 \"AUTH\" when facing an \"auth-required: \" rejection and try again",
},
&cli.BoolFlag{
Name: "nevent",
Usage: "print the nevent code (to stderr) after the event is published",
},
&cli.BoolFlag{
Name: "nson",
Usage: "encode the event using NSON",
Expand Down Expand Up @@ -229,6 +234,7 @@ example:
stdout(result)

// publish to relays
successRelays := make([]string, 0, len(relays))
if len(relays) > 0 {
os.Stdout.Sync()
for _, relay := range relays {
Expand All @@ -241,6 +247,7 @@ example:
if err == nil {
// published fine
log("success.\n")
successRelays = append(successRelays, relay.URL)
continue // continue to next relay
}

Expand All @@ -259,6 +266,10 @@ example:
}
log("failed: %s\n", err)
}
if len(successRelays) > 0 && c.Bool("nevent") {
nevent, _ := nip19.EncodeEvent(evt.ID, successRelays, evt.PubKey)
log(nevent + "\n")
}
}
}

Expand Down

0 comments on commit 3dfcec6

Please sign in to comment.