From 967a08fb65192d548270f797620436b92e85f86d Mon Sep 17 00:00:00 2001 From: Alessio Perugini Date: Sun, 5 Jan 2025 15:21:41 +0100 Subject: [PATCH] nip17: fix nil pointer Fixes a nil pointer when the Publish succeeds. In that case the err is nil, and calling .Error() on nil causes a nil pointer exception. Reproduced at: https://play.golang.com/p/ps8d82Qt9kO --- nip17/nip17.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nip17/nip17.go b/nip17/nip17.go index 7ca8354..fe04b18 100644 --- a/nip17/nip17.go +++ b/nip17/nip17.go @@ -55,7 +55,7 @@ func PublishMessage( } err = r.Publish(ctx, event) - if strings.HasPrefix(err.Error(), "auth-required:") { + if err != nil && strings.HasPrefix(err.Error(), "auth-required:") { authErr := r.Auth(ctx, func(ae *nostr.Event) error { return kr.SignEvent(ctx, ae) }) if authErr == nil { err = r.Publish(ctx, event)