mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-05-21 16:09:57 +02:00
nip46: fix messages nip04->nip44.
This commit is contained in:
parent
40535e6b19
commit
57683d4cae
@ -183,12 +183,12 @@ func (p *DynamicSigner) HandleRequest(ctx context.Context, event *nostr.Event) (
|
||||
}
|
||||
case "nip44_encrypt":
|
||||
if len(req.Params) != 2 {
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip04_encrypt'")
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip44_encrypt'")
|
||||
break
|
||||
}
|
||||
thirdPartyPubkey := req.Params[0]
|
||||
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
|
||||
resultErr = fmt.Errorf("first argument to 'nip44_encrypt' is not a pubkey string")
|
||||
break
|
||||
}
|
||||
if p.authorizeEncryption != nil && !p.authorizeEncryption(event.PubKey, secret) {
|
||||
@ -205,12 +205,12 @@ func (p *DynamicSigner) HandleRequest(ctx context.Context, event *nostr.Event) (
|
||||
result = ciphertext
|
||||
case "nip44_decrypt":
|
||||
if len(req.Params) != 2 {
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip04_decrypt'")
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip44_decrypt'")
|
||||
break
|
||||
}
|
||||
thirdPartyPubkey := req.Params[0]
|
||||
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
|
||||
resultErr = fmt.Errorf("first argument to 'nip44_decrypt' is not a pubkey string")
|
||||
break
|
||||
}
|
||||
if p.authorizeEncryption != nil && !p.authorizeEncryption(event.PubKey, secret) {
|
||||
|
@ -142,12 +142,12 @@ func (p *StaticKeySigner) HandleRequest(_ context.Context, event *nostr.Event) (
|
||||
harmless = true
|
||||
case "nip44_encrypt":
|
||||
if len(req.Params) != 2 {
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip04_encrypt'")
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip44_encrypt'")
|
||||
break
|
||||
}
|
||||
thirdPartyPubkey := req.Params[0]
|
||||
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||
resultErr = fmt.Errorf("first argument to 'nip04_encrypt' is not a pubkey string")
|
||||
resultErr = fmt.Errorf("first argument to 'nip44_encrypt' is not a pubkey string")
|
||||
break
|
||||
}
|
||||
plaintext := req.Params[1]
|
||||
@ -165,12 +165,12 @@ func (p *StaticKeySigner) HandleRequest(_ context.Context, event *nostr.Event) (
|
||||
result = ciphertext
|
||||
case "nip44_decrypt":
|
||||
if len(req.Params) != 2 {
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip04_decrypt'")
|
||||
resultErr = fmt.Errorf("wrong number of arguments to 'nip44_decrypt'")
|
||||
break
|
||||
}
|
||||
thirdPartyPubkey := req.Params[0]
|
||||
if !nostr.IsValidPublicKey(thirdPartyPubkey) {
|
||||
resultErr = fmt.Errorf("first argument to 'nip04_decrypt' is not a pubkey string")
|
||||
resultErr = fmt.Errorf("first argument to 'nip44_decrypt' is not a pubkey string")
|
||||
break
|
||||
}
|
||||
ciphertext := req.Params[1]
|
||||
|
Loading…
x
Reference in New Issue
Block a user