mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 00:59:07 -04:00
support nostr: prefix.
This commit is contained in:
parent
6c97f12418
commit
d6ab152867
12
decode.go
12
decode.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
"github.com/nbd-wtf/go-nostr/nip19"
|
"github.com/nbd-wtf/go-nostr/nip19"
|
||||||
|
@ -15,10 +16,10 @@ var decode = &cli.Command{
|
||||||
Name: "decode",
|
Name: "decode",
|
||||||
Usage: "decodes nip19, nip21, nip05 or hex entities",
|
Usage: "decodes nip19, nip21, nip05 or hex entities",
|
||||||
Description: `example usage:
|
Description: `example usage:
|
||||||
nak decode
|
nak decode npub1uescmd5krhrmj9rcura833xpke5eqzvcz5nxjw74ufeewf2sscxq4g7chm
|
||||||
nak decode
|
nak decode nevent1qqs29yet5tp0qq5xu5qgkeehkzqh5qu46739axzezcxpj4tjlkx9j7gpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5sh59ud
|
||||||
nak decode
|
nak decode nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpz4mhxue69uhk2er9dchxummnw3ezumrpdejqz8thwden5te0dehhxarj94c82c3wwajkcmr0wfjx2u3wdejhgqgcwaehxw309aex2mrp0yhxummnw3exzarf9e3k7mgnp0sh5
|
||||||
nak decode`,
|
nak decode nsec1jrmyhtjhgd9yqalps8hf9mayvd58852gtz66m7tqpacjedkp6kxq4dyxsr`,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "id",
|
Name: "id",
|
||||||
|
@ -38,6 +39,9 @@ var decode = &cli.Command{
|
||||||
return fmt.Errorf("invalid number of arguments, need just one")
|
return fmt.Errorf("invalid number of arguments, need just one")
|
||||||
}
|
}
|
||||||
input := args.First()
|
input := args.First()
|
||||||
|
if strings.HasPrefix(input, "nostr:") {
|
||||||
|
input = input[6:]
|
||||||
|
}
|
||||||
|
|
||||||
var decodeResult DecodeResult
|
var decodeResult DecodeResult
|
||||||
if b, err := hex.DecodeString(input); err == nil {
|
if b, err := hex.DecodeString(input); err == nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user