Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: handle events before lnclient is initialized #236

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ func (svc *Service) HandleEvent(ctx context.Context, event *nostr.Event) (result
return nil, nil
}

if svc.lnClient == nil {
svc.Logger.WithFields(logrus.Fields{
"nostrPubkey": event.PubKey,
}).Errorf("Received an event before ln client is initialized")

ss, err := nip04.ComputeSharedSecret(event.PubKey, svc.cfg.NostrSecretKey)
if err != nil {
return nil, err
}
return svc.createResponse(event, Nip47Response{
Error: &Nip47Error{
Code: NIP_47_ERROR_INTERNAL,
rolznz marked this conversation as resolved.
Show resolved Hide resolved
Message: "The public key does not have a ln client initialized.",
},
}, ss)
}

app := App{}
err = svc.db.First(&app, &App{
NostrPubkey: event.PubKey,
Expand All @@ -287,13 +304,12 @@ func (svc *Service) HandleEvent(ctx context.Context, event *nostr.Event) (result
if err != nil {
return nil, err
}
resp, _ := svc.createResponse(event, Nip47Response{
return svc.createResponse(event, Nip47Response{
Error: &Nip47Error{
Code: NIP_47_ERROR_UNAUTHORIZED,
Message: "The public key does not have a wallet connected.",
},
}, ss)
return resp, err
}

svc.Logger.WithFields(logrus.Fields{
Expand Down
Loading