mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 09:09:08 -04:00
fix reading hex secret key from input.
This commit is contained in:
parent
0d46d48881
commit
bda18e035a
|
@ -147,12 +147,12 @@ func gatherSecretKeyFromArguments(c *cli.Context) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to decrypt: %w", err)
|
return "", fmt.Errorf("failed to decrypt: %w", err)
|
||||||
}
|
}
|
||||||
|
} else if bsec, err := hex.DecodeString(strings.Repeat("0", 64-len(sec)) + sec); err == nil {
|
||||||
|
sec = hex.EncodeToString(bsec)
|
||||||
} else if prefix, hexvalue, err := nip19.Decode(sec); err != nil {
|
} else if prefix, hexvalue, err := nip19.Decode(sec); err != nil {
|
||||||
return "", fmt.Errorf("invalid nsec: %w", err)
|
return "", fmt.Errorf("invalid nsec: %w", err)
|
||||||
} else if prefix == "nsec" {
|
} else if prefix == "nsec" {
|
||||||
sec = hexvalue.(string)
|
sec = hexvalue.(string)
|
||||||
} else if bsec, err := hex.DecodeString(strings.Repeat("0", 64-len(sec)) + sec); err == nil {
|
|
||||||
sec = hex.EncodeToString(bsec)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok := nostr.IsValid32ByteHex(sec); !ok {
|
if ok := nostr.IsValid32ByteHex(sec); !ok {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user