diff --git a/encrypt_decrypt.go b/encrypt_decrypt.go index e517fdf..b4cc5c5 100644 --- a/encrypt_decrypt.go +++ b/encrypt_decrypt.go @@ -58,7 +58,7 @@ var encrypt = &cli.Command{ stdout(ciphertext) } } else { - kr, err := gatherKeyerFromArguments(ctx, c) + kr, _, err := gatherKeyerFromArguments(ctx, c) if err != nil { return err } @@ -123,7 +123,7 @@ var decrypt = &cli.Command{ stdout(plaintext) } } else { - kr, err := gatherKeyerFromArguments(ctx, c) + kr, _, err := gatherKeyerFromArguments(ctx, c) if err != nil { return err } diff --git a/event.go b/event.go index 909803f..6a93c7a 100644 --- a/event.go +++ b/event.go @@ -148,11 +148,10 @@ example: } }() - kr, err := gatherKeyerFromArguments(ctx, c) + kr, sec, err := gatherKeyerFromArguments(ctx, c) if err != nil { return err } - sec, _, _ := gatherSecretKeyOrBunkerFromArguments(ctx, c) doAuth := c.Bool("auth") @@ -254,7 +253,8 @@ example: } if evt.Sig == "" || mustRehashAndResign { - if numSigners := c.Uint("musig"); numSigners > 1 && sec != "" { + if numSigners := c.Uint("musig"); numSigners > 1 { + // must do musig pubkeys := c.StringSlice("musig-pubkey") secNonce := c.String("musig-nonce-secret") pubNonces := c.StringSlice("musig-nonce") @@ -304,7 +304,7 @@ example: } // error publishing - if strings.HasPrefix(err.Error(), "msg: auth-required:") && (sec != "" || bunker != nil) && doAuth { + if strings.HasPrefix(err.Error(), "msg: auth-required:") && kr != nil && doAuth { // if the relay is requesting auth and we can auth, let's do it pk, _ := kr.GetPublicKey(ctx) log("performing auth as %s... ", pk) diff --git a/helpers_key.go b/helpers_key.go index 62a6f80..19f35c3 100644 --- a/helpers_key.go +++ b/helpers_key.go @@ -38,20 +38,20 @@ var defaultKeyFlags = []cli.Flag{ }, } -func gatherKeyerFromArguments(ctx context.Context, c *cli.Command) (keyer.Keyer, error) { +func gatherKeyerFromArguments(ctx context.Context, c *cli.Command) (nostr.Keyer, string, error) { key, bunker, err := gatherSecretKeyOrBunkerFromArguments(ctx, c) if err != nil { - return nil, err + return nil, "", err } - var kr keyer.Keyer + var kr nostr.Keyer if bunker != nil { kr = keyer.NewBunkerSignerFromBunkerClient(bunker) } else { kr, err = keyer.NewPlainKeySigner(key) } - return kr, err + return kr, key, err } func gatherSecretKeyOrBunkerFromArguments(ctx context.Context, c *cli.Command) (string, *nip46.BunkerClient, error) { diff --git a/relay.go b/relay.go index 3e8ce9f..381bf65 100644 --- a/relay.go +++ b/relay.go @@ -95,7 +95,7 @@ var relay = &cli.Command{ return nil } - kr, err := gatherKeyerFromArguments(ctx, c) + kr, _, err := gatherKeyerFromArguments(ctx, c) if err != nil { return err } diff --git a/req.go b/req.go index 62f666f..f4a143a 100644 --- a/req.go +++ b/req.go @@ -80,7 +80,7 @@ example: if !c.Bool("auth") && !c.Bool("force-pre-auth") { return fmt.Errorf("auth not authorized") } - kr, err := gatherKeyerFromArguments(ctx, c) + kr, _, err := gatherKeyerFromArguments(ctx, c) if err != nil { return err }