key: honor --with-parity when public key comes from --sec/default key instead of silently ignoring it.

This commit is contained in:
Yasuhiro Matsumoto
2026-08-18 13:21:39 +09:00
parent 510c0039cc
commit ba85ea8806

10
key.go
View File

@@ -59,10 +59,18 @@ var public = &cli.Command{
Action: func(ctx context.Context, c *cli.Command) error {
args := c.Args().Slice()
if len(args) == 0 && !isPiped() {
kr, _, err := gatherKeyerFromArguments(ctx, c)
kr, sk, err := gatherKeyerFromArguments(ctx, c)
if err != nil {
return err
}
if c.Bool("with-parity") {
if sk == (nostr.SecretKey{}) {
return fmt.Errorf("--with-parity requires a plain secret key, not a bunker")
}
_, pk := btcec.PrivKeyFromBytes(sk[:])
stdout(hex.EncodeToString(pk.SerializeCompressed()))
return nil
}
pk, err := kr.GetPublicKey(ctx)
if err != nil {
return fmt.Errorf("failed to get public key: %w", err)