mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-25 09:09:08 -05:00
--connect-as to specify client pubkey when using --connect to bunker
This commit is contained in:
parent
b7a7e0504f
commit
6626001dd2
5
event.go
5
event.go
|
@ -48,6 +48,11 @@ example:
|
||||||
Name: "connect",
|
Name: "connect",
|
||||||
Usage: "sign event using NIP-46, expects a bunker://... URL",
|
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{
|
&cli.BoolFlag{
|
||||||
Name: "envelope",
|
Name: "envelope",
|
||||||
Usage: "print the event enveloped in a [\"EVENT\", ...] message ready to be sent to a relay",
|
Usage: "print the event enveloped in a [\"EVENT\", ...] message ready to be sent to a relay",
|
||||||
|
|
|
@ -134,7 +134,12 @@ func gatherSecretKeyOrBunkerFromArguments(c *cli.Context) (string, *nip46.Bunker
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if bunkerURL := c.String("connect"); bunkerURL != "" {
|
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)
|
bunker, err := nip46.ConnectBunker(c.Context, clientKey, bunkerURL, nil)
|
||||||
return "", bunker, err
|
return "", bunker, err
|
||||||
}
|
}
|
||||||
|
|
5
req.go
5
req.go
|
@ -117,6 +117,11 @@ example:
|
||||||
Name: "connect",
|
Name: "connect",
|
||||||
Usage: "sign AUTH using NIP-46, expects a bunker://... URL",
|
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...]",
|
ArgsUsage: "[relay...]",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user