diff --git a/event.go b/event.go index eb8cd05..319ed38 100644 --- a/event.go +++ b/event.go @@ -48,6 +48,11 @@ example: Name: "connect", Usage: "sign event using NIP-46, expects a bunker://... URL", }, + &cli.StringFlag{ + Name: "connect-as", + Usage: "private key to when communicating with the bunker given on --connect", + DefaultText: "a random key", + }, &cli.BoolFlag{ Name: "envelope", Usage: "print the event enveloped in a [\"EVENT\", ...] message ready to be sent to a relay", diff --git a/helpers.go b/helpers.go index 6a2ce76..3b8f015 100644 --- a/helpers.go +++ b/helpers.go @@ -134,7 +134,12 @@ func gatherSecretKeyOrBunkerFromArguments(c *cli.Context) (string, *nip46.Bunker var err error if bunkerURL := c.String("connect"); bunkerURL != "" { - clientKey := nostr.GeneratePrivateKey() + clientKey := c.String("connect-as") + if clientKey != "" { + clientKey = strings.Repeat("0", 64-len(clientKey)) + clientKey + } else { + clientKey = nostr.GeneratePrivateKey() + } bunker, err := nip46.ConnectBunker(c.Context, clientKey, bunkerURL, nil) return "", bunker, err } diff --git a/req.go b/req.go index 5801b39..aceb9ff 100644 --- a/req.go +++ b/req.go @@ -117,6 +117,11 @@ example: Name: "connect", Usage: "sign AUTH using NIP-46, expects a bunker://... URL", }, + &cli.StringFlag{ + Name: "connect-as", + Usage: "private key to when communicating with the bunker given on --connect", + DefaultText: "a random key", + }, }, ArgsUsage: "[relay...]", Action: func(c *cli.Context) error {