Skip to content

Commit 2586144

Browse files
committed
replace usage of IsValidPublicKeyHex() in subpackages.
1 parent 9457c5a commit 2586144

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

nip29/group.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (group *Group) MergeInAdminsEvent(evt *nostr.Event) error {
150150
if tag[0] != "p" {
151151
continue
152152
}
153-
if !nostr.IsValidPublicKeyHex(tag[1]) {
153+
if !nostr.IsValid32ByteHex(tag[1]) {
154154
continue
155155
}
156156

@@ -186,7 +186,7 @@ func (group *Group) MergeInMembersEvent(evt *nostr.Event) error {
186186
if tag[0] != "p" {
187187
continue
188188
}
189-
if !nostr.IsValidPublicKeyHex(tag[1]) {
189+
if !nostr.IsValid32ByteHex(tag[1]) {
190190
continue
191191
}
192192

nip29/relay/relay.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
2424
nostr.KindSimpleGroupAddUser: func(evt *nostr.Event) (Action, error) {
2525
targets := make([]string, 0, len(evt.Tags))
2626
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
27-
if !nostr.IsValidPublicKeyHex(tag[1]) {
27+
if !nostr.IsValid32ByteHex(tag[1]) {
2828
return nil, fmt.Errorf("")
2929
}
3030
targets = append(targets, tag[1])
@@ -37,7 +37,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
3737
nostr.KindSimpleGroupRemoveUser: func(evt *nostr.Event) (Action, error) {
3838
targets := make([]string, 0, len(evt.Tags))
3939
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
40-
if !nostr.IsValidPublicKeyHex(tag[1]) {
40+
if !nostr.IsValid32ByteHex(tag[1]) {
4141
return nil, fmt.Errorf("invalid public key hex")
4242
}
4343
targets = append(targets, tag[1])
@@ -81,7 +81,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
8181

8282
targets := make([]string, 0, nTags-1)
8383
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
84-
if !nostr.IsValidPublicKeyHex(tag[1]) {
84+
if !nostr.IsValid32ByteHex(tag[1]) {
8585
return nil, fmt.Errorf("invalid public key hex")
8686
}
8787
targets = append(targets, tag[1])
@@ -107,7 +107,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
107107

108108
targets := make([]string, 0, nTags-1)
109109
for _, tag := range evt.Tags.GetAll([]string{"p", ""}) {
110-
if !nostr.IsValidPublicKeyHex(tag[1]) {
110+
if !nostr.IsValid32ByteHex(tag[1]) {
111111
return nil, fmt.Errorf("invalid public key hex")
112112
}
113113
targets = append(targets, tag[1])
@@ -127,7 +127,7 @@ var moderationActionFactories = map[int]func(*nostr.Event) (Action, error){
127127

128128
targets := make([]string, len(tags))
129129
for i, tag := range tags {
130-
if nostr.IsValidPublicKeyHex(tag[1]) {
130+
if nostr.IsValid32ByteHex(tag[1]) {
131131
targets[i] = tag[1]
132132
} else {
133133
return nil, fmt.Errorf("invalid event id hex")

nip46/dynamic-signer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (p *DynamicSigner) HandleRequest(event *nostr.Event) (
8181
}
8282

8383
targetUser := event.Tags.GetFirst([]string{"p", ""})
84-
if targetUser == nil || !nostr.IsValidPublicKeyHex((*targetUser)[1]) {
84+
if targetUser == nil || !nostr.IsValid32ByteHex((*targetUser)[1]) {
8585
return req, resp, eventResponse, false, fmt.Errorf("invalid \"p\" tag")
8686
}
8787

@@ -153,7 +153,7 @@ func (p *DynamicSigner) HandleRequest(event *nostr.Event) (
153153
break
154154
}
155155
thirdPartyPubkey := req.Params[0]
156-
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
156+
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
157157
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
158158
break
159159
}
@@ -179,7 +179,7 @@ func (p *DynamicSigner) HandleRequest(event *nostr.Event) (
179179
break
180180
}
181181
thirdPartyPubkey := req.Params[0]
182-
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
182+
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
183183
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
184184
break
185185
}

nip46/static-key-signer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (p *StaticKeySigner) HandleRequest(event *nostr.Event) (
134134
break
135135
}
136136
thirdPartyPubkey := req.Params[0]
137-
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
137+
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
138138
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
139139
break
140140
}
@@ -156,7 +156,7 @@ func (p *StaticKeySigner) HandleRequest(event *nostr.Event) (
156156
break
157157
}
158158
thirdPartyPubkey := req.Params[0]
159-
if !nostr.IsValidPublicKeyHex(thirdPartyPubkey) {
159+
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
160160
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
161161
break
162162
}

nip52/calendar_event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func ParseCalendarEvent(event nostr.Event) CalendarEvent {
7575
case "g":
7676
calev.Geohashes = append(calev.Geohashes, tag[1])
7777
case "p":
78-
if nostr.IsValidPublicKeyHex(tag[1]) {
78+
if nostr.IsValid32ByteHex(tag[1]) {
7979
part := Participant{
8080
PubKey: tag[1],
8181
}

nip53/nip53.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func ParseLiveEvent(event nostr.Event) LiveEvent {
6464
case "recording":
6565
liev.Recording = append(liev.Recording, tag[1])
6666
case "p":
67-
if nostr.IsValidPublicKeyHex(tag[1]) {
67+
if nostr.IsValid32ByteHex(tag[1]) {
6868
part := Participant{
6969
PubKey: tag[1],
7070
}

0 commit comments

Comments
 (0)