From c90e61dbec24db08a6dadf288aed10c572efd923 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 7 Aug 2024 11:46:07 -0300 Subject: [PATCH] set .DisableSliceFlagSeparator to true. fixes nostr:nevent1qqs9qwgwnr2rzguzrgt99hhhyv8e84mcdr4mnk86uvm6ndjvzl4rjxqpzpmhxue69uhkztnwdaejumr0dshsz9mhwden5te0vf5hgcm0d9hx2u3wwdhkx6tpdshszxnhwden5te0vfhhxarj9ekx2cm5w4exjene9ehx2ap0j8u0fj --- bunker.go | 9 +++++---- count.go | 7 ++++--- decode.go | 1 + encode.go | 19 +++++++++++++------ event.go | 1 + fetch.go | 1 + key.go | 44 +++++++++++++++++++++++++------------------- main.go | 11 ++++++----- musig2.go | 2 +- relay.go | 3 ++- req.go | 1 + verify.go | 1 + 12 files changed, 61 insertions(+), 39 deletions(-) diff --git a/bunker.go b/bunker.go index 5de6ec6..47ff50c 100644 --- a/bunker.go +++ b/bunker.go @@ -19,10 +19,11 @@ import ( ) var bunker = &cli.Command{ - Name: "bunker", - Usage: "starts a NIP-46 signer daemon with the given --sec key", - ArgsUsage: "[relay...]", - Description: ``, + Name: "bunker", + Usage: "starts a NIP-46 signer daemon with the given --sec key", + ArgsUsage: "[relay...]", + Description: ``, + DisableSliceFlagSeparator: true, Flags: []cli.Flag{ &cli.StringFlag{ Name: "sec", diff --git a/count.go b/count.go index d1d2286..906b516 100644 --- a/count.go +++ b/count.go @@ -12,9 +12,10 @@ import ( ) var count = &cli.Command{ - Name: "count", - Usage: "generates encoded COUNT messages and optionally use them to talk to relays", - Description: `outputs a NIP-45 request (the flags are mostly the same as 'nak req').`, + Name: "count", + Usage: "generates encoded COUNT messages and optionally use them to talk to relays", + Description: `outputs a NIP-45 request (the flags are mostly the same as 'nak req').`, + DisableSliceFlagSeparator: true, Flags: []cli.Flag{ &cli.StringSliceFlag{ Name: "author", diff --git a/decode.go b/decode.go index d27fe68..95aa1b8 100644 --- a/decode.go +++ b/decode.go @@ -20,6 +20,7 @@ var decode = &cli.Command{ nak decode nevent1qqs29yet5tp0qq5xu5qgkeehkzqh5qu46739axzezcxpj4tjlkx9j7gpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5sh59ud nak decode nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpz4mhxue69uhk2er9dchxummnw3ezumrpdejqz8thwden5te0dehhxarj94c82c3wwajkcmr0wfjx2u3wdejhgqgcwaehxw309aex2mrp0yhxummnw3exzarf9e3k7mgnp0sh5 nak decode nsec1jrmyhtjhgd9yqalps8hf9mayvd58852gtz66m7tqpacjedkp6kxq4dyxsr`, + DisableSliceFlagSeparator: true, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "id", diff --git a/encode.go b/encode.go index 3506ad4..17d097d 100644 --- a/encode.go +++ b/encode.go @@ -25,10 +25,12 @@ var encode = &cli.Command{ } return nil }, + DisableSliceFlagSeparator: true, Commands: []*cli.Command{ { - Name: "npub", - Usage: "encode a hex public key into bech32 'npub' format", + Name: "npub", + Usage: "encode a hex public key into bech32 'npub' format", + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for target := range getStdinLinesOrArguments(c.Args()) { if ok := nostr.IsValidPublicKey(target); !ok { @@ -48,8 +50,9 @@ var encode = &cli.Command{ }, }, { - Name: "nsec", - Usage: "encode a hex private key into bech32 'nsec' format", + Name: "nsec", + Usage: "encode a hex private key into bech32 'nsec' format", + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for target := range getStdinLinesOrArguments(c.Args()) { if ok := nostr.IsValid32ByteHex(target); !ok { @@ -78,6 +81,7 @@ var encode = &cli.Command{ Usage: "attach relay hints to nprofile code", }, }, + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for target := range getStdinLinesOrArguments(c.Args()) { if ok := nostr.IsValid32ByteHex(target); !ok { @@ -116,6 +120,7 @@ var encode = &cli.Command{ Usage: "attach an author pubkey as a hint to the nevent code", }, }, + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for target := range getStdinLinesOrArguments(c.Args()) { if ok := nostr.IsValid32ByteHex(target); !ok { @@ -174,6 +179,7 @@ var encode = &cli.Command{ Usage: "attach relay hints to naddr code", }, }, + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for d := range getStdinLinesOrBlank() { pubkey := c.String("pubkey") @@ -211,8 +217,9 @@ var encode = &cli.Command{ }, }, { - Name: "note", - Usage: "generate note1 event codes (not recommended)", + Name: "note", + Usage: "generate note1 event codes (not recommended)", + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for target := range getStdinLinesOrArguments(c.Args()) { if ok := nostr.IsValid32ByteHex(target); !ok { diff --git a/event.go b/event.go index 28db9bb..df1dbb0 100644 --- a/event.go +++ b/event.go @@ -31,6 +31,7 @@ if an event -- or a partial event -- is given on stdin, the flags can be used to example: echo '{"id":"a889df6a387419ff204305f4c2d296ee328c3cd4f8b62f205648a541b4554dfb","pubkey":"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5","created_at":1698623783,"kind":1,"tags":[],"content":"hello from the nostr army knife","sig":"84876e1ee3e726da84e5d195eb79358b2b3eaa4d9bd38456fde3e8a2af3f1cd4cda23f23fda454869975b3688797d4c66e12f4c51c1b43c6d2997c5e61865661"}' | nak event wss://offchain.pub echo '{"tags": [["t", "spam"]]}' | nak event -c 'this is spam'`, + DisableSliceFlagSeparator: true, Flags: []cli.Flag{ &cli.StringFlag{ Name: "sec", diff --git a/fetch.go b/fetch.go index 88009d7..014f8a9 100644 --- a/fetch.go +++ b/fetch.go @@ -15,6 +15,7 @@ var fetch = &cli.Command{ Description: `example usage: nak fetch nevent1qqsxrwm0hd3s3fddh4jc2574z3xzufq6qwuyz2rvv3n087zvym3dpaqprpmhxue69uhhqatzd35kxtnjv4kxz7tfdenju6t0xpnej4 echo npub1h8spmtw9m2huyv6v2j2qd5zv956z2zdugl6mgx02f2upffwpm3nqv0j4ps | nak fetch --relay wss://relay.nostr.band`, + DisableSliceFlagSeparator: true, Flags: []cli.Flag{ &cli.StringSliceFlag{ Name: "relay", diff --git a/key.go b/key.go index 21f3aa6..d925ba6 100644 --- a/key.go +++ b/key.go @@ -18,9 +18,10 @@ import ( ) var key = &cli.Command{ - Name: "key", - Usage: "operations on secret keys: generate, derive, encrypt, decrypt.", - Description: ``, + Name: "key", + Usage: "operations on secret keys: generate, derive, encrypt, decrypt.", + Description: ``, + DisableSliceFlagSeparator: true, Commands: []*cli.Command{ generate, public, @@ -31,9 +32,10 @@ var key = &cli.Command{ } var generate = &cli.Command{ - Name: "generate", - Usage: "generates a secret key", - Description: ``, + Name: "generate", + Usage: "generates a secret key", + Description: ``, + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { sec := nostr.GeneratePrivateKey() stdout(sec) @@ -42,10 +44,11 @@ var generate = &cli.Command{ } var public = &cli.Command{ - Name: "public", - Usage: "computes a public key from a secret key", - Description: ``, - ArgsUsage: "[secret]", + Name: "public", + Usage: "computes a public key from a secret key", + Description: ``, + ArgsUsage: "[secret]", + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for sec := range getSecretKeysFromStdinLinesOrSlice(ctx, c, c.Args().Slice()) { pubkey, err := nostr.GetPublicKey(sec) @@ -60,10 +63,11 @@ var public = &cli.Command{ } var encrypt = &cli.Command{ - Name: "encrypt", - Usage: "encrypts a secret key and prints an ncryptsec code", - Description: `uses the NIP-49 standard.`, - ArgsUsage: " ", + Name: "encrypt", + Usage: "encrypts a secret key and prints an ncryptsec code", + Description: `uses the NIP-49 standard.`, + ArgsUsage: " ", + DisableSliceFlagSeparator: true, Flags: []cli.Flag{ &cli.IntFlag{ Name: "logn", @@ -98,10 +102,11 @@ var encrypt = &cli.Command{ } var decrypt = &cli.Command{ - Name: "decrypt", - Usage: "takes an ncrypsec and a password and decrypts it into an nsec", - Description: `uses the NIP-49 standard.`, - ArgsUsage: " ", + Name: "decrypt", + Usage: "takes an ncrypsec and a password and decrypts it into an nsec", + Description: `uses the NIP-49 standard.`, + ArgsUsage: " ", + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { var ncryptsec string var password string @@ -151,7 +156,8 @@ var combine = &cli.Command{ Description: `The public keys must have 33 bytes (66 characters hex), with the 02 or 03 prefix. It is common in Nostr to drop that first byte, so you'll have to derive the public keys again from the private keys in order to get it back. However, if the intent is to check if two existing Nostr pubkeys match a given combined pubkey, then it might be sufficient to calculate the combined key for all the possible combinations of pubkeys in the input.`, - ArgsUsage: "[pubkey...]", + ArgsUsage: "[pubkey...]", + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { type Combination struct { Variants []string `json:"input_variants"` diff --git a/main.go b/main.go index 3861933..be8780a 100644 --- a/main.go +++ b/main.go @@ -8,11 +8,12 @@ import ( ) var app = &cli.Command{ - Name: "nak", - Suggest: true, - UseShortOptionHandling: true, - AllowFlagsAfterArguments: true, - Usage: "the nostr army knife command-line tool", + Name: "nak", + Suggest: true, + UseShortOptionHandling: true, + AllowFlagsAfterArguments: true, + Usage: "the nostr army knife command-line tool", + DisableSliceFlagSeparator: true, Commands: []*cli.Command{ req, count, diff --git a/musig2.go b/musig2.go index 201c057..1775125 100644 --- a/musig2.go +++ b/musig2.go @@ -16,7 +16,7 @@ import ( ) func performMusig( - ctx context.Context, + _ context.Context, sec string, evt *nostr.Event, numSigners int, diff --git a/relay.go b/relay.go index 07d6391..f663bc1 100644 --- a/relay.go +++ b/relay.go @@ -22,7 +22,8 @@ var relay = &cli.Command{ Usage: "gets the relay information document for the given relay, as JSON", Description: `example: nak relay nostr.wine`, - ArgsUsage: "", + ArgsUsage: "", + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for url := range getStdinLinesOrArguments(c.Args()) { if url == "" { diff --git a/req.go b/req.go index 7835d9f..10713a8 100644 --- a/req.go +++ b/req.go @@ -27,6 +27,7 @@ it can also take a filter from stdin, optionally modify it with flags and send i example: echo '{"kinds": [1], "#t": ["test"]}' | nak req -l 5 -k 4549 --tag t=spam wss://nostr-pub.wellorder.net`, + DisableSliceFlagSeparator: true, Flags: []cli.Flag{ &cli.StringSliceFlag{ Name: "author", diff --git a/verify.go b/verify.go index 1bfc979..e71fc47 100644 --- a/verify.go +++ b/verify.go @@ -15,6 +15,7 @@ var verify = &cli.Command{ echo '{"id":"a889df6a387419ff204305f4c2d296ee328c3cd4f8b62f205648a541b4554dfb","pubkey":"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5","created_at":1698623783,"kind":1,"tags":[],"content":"hello from the nostr army knife","sig":"84876e1ee3e726da84e5d195eb79358b2b3eaa4d9bd38456fde3e8a2af3f1cd4cda23f23fda454869975b3688797d4c66e12f4c51c1b43c6d2997c5e61865661"}' | nak verify it outputs nothing if the verification is successful.`, + DisableSliceFlagSeparator: true, Action: func(ctx context.Context, c *cli.Command) error { for stdinEvent := range getStdinLinesOrArguments(c.Args()) { evt := nostr.Event{}