Merge pull request #196 from mattn/fix/key-public-with-parity

key: honor --with-parity when the key comes from --sec
This commit is contained in:
mattn
2026-08-18 04:56:16 +00:00
committed by GitHub

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)