mirror of
https://github.com/fiatjaf/nak.git
synced 2026-10-05 15:18:23 +00:00
trim nostr: prefix so it works again on fetch and flags.
This commit is contained in:
@@ -43,6 +43,7 @@ var fetch = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for code := range getStdinLinesOrArguments(c.Args()) {
|
for code := range getStdinLinesOrArguments(c.Args()) {
|
||||||
|
code = strings.TrimPrefix(code, "nostr:")
|
||||||
var filter nostr.Filter
|
var filter nostr.Filter
|
||||||
var authorHint nostr.PubKey
|
var authorHint nostr.PubKey
|
||||||
relays := c.StringSlice("relay")
|
relays := c.StringSlice("relay")
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
@@ -253,6 +254,7 @@ func (t pubKeyOrAddressValue) ToString(b PubKeyOrAddress) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *pubKeyOrAddressValue) Set(value string) error {
|
func (t *pubKeyOrAddressValue) Set(value string) error {
|
||||||
|
value = strings.TrimPrefix(value, "nostr:")
|
||||||
pubkey, err1 := parsePubKey(value)
|
pubkey, err1 := parsePubKey(value)
|
||||||
if err1 == nil {
|
if err1 == nil {
|
||||||
t.value = PubKeyOrAddress{PubKey: pubkey}
|
t.value = PubKeyOrAddress{PubKey: pubkey}
|
||||||
|
|||||||
@@ -476,6 +476,7 @@ func askConfirmation(msg string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parsePubKey(value string) (nostr.PubKey, error) {
|
func parsePubKey(value string) (nostr.PubKey, error) {
|
||||||
|
value = strings.TrimPrefix(value, "nostr:")
|
||||||
if nip05.IsValidIdentifier(value) {
|
if nip05.IsValidIdentifier(value) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
||||||
pp, err := nip05.QueryIdentifier(ctx, value)
|
pp, err := nip05.QueryIdentifier(ctx, value)
|
||||||
@@ -508,6 +509,7 @@ func parsePubKey(value string) (nostr.PubKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseSecretKey(input string) (nostr.SecretKey, error) {
|
func parseSecretKey(input string) (nostr.SecretKey, error) {
|
||||||
|
input = strings.TrimPrefix(input, "nostr:")
|
||||||
if prefix, ski, err := nip19.Decode(input); err == nil && prefix == "nsec" {
|
if prefix, ski, err := nip19.Decode(input); err == nil && prefix == "nsec" {
|
||||||
return ski.(nostr.SecretKey), nil
|
return ski.(nostr.SecretKey), nil
|
||||||
}
|
}
|
||||||
@@ -521,6 +523,7 @@ func parseSecretKey(input string) (nostr.SecretKey, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseEventID(value string) (nostr.ID, error) {
|
func parseEventID(value string) (nostr.ID, error) {
|
||||||
|
value = strings.TrimPrefix(value, "nostr:")
|
||||||
id, err := nostr.IDFromHex(value)
|
id, err := nostr.IDFromHex(value)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return id, nil
|
return id, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user