mirror of
https://github.com/fiatjaf/nak.git
synced 2026-09-12 13:42:57 +02:00
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:
10
key.go
10
key.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user