fix: properly handle async NostrSend calls for Kind 21002 responses #1

Merged
padreug merged 2 commits from feature/nostr-send-async into dev 2026-01-25 19:39:55 +00:00
Owner

Summary

Fixes an issue where ShockWallet would show "Debit request failed" even though the payment succeeded, because Lightning.Pub wasn't properly sending Kind 21002 responses back to the wallet.

Problem

The NostrSend type was incorrectly typed as returning void when it actually returns Promise<void>. This caused async errors to be silently swallowed when sending Kind 21002 (ndebit) responses.

Solution

  1. Update type signature to return Promise<void>
  2. Add proper error handling with .catch() logging
  3. Update all call sites to handle the async nature

Commits

  1. fix(nostr): update NostrSend type to Promise<void> with error handling
  2. fix(handlers): await NostrSend calls throughout codebase

Files Changed

  • src/services/nostr/nostrPool.ts - Type definition
  • src/services/nostr/sender.ts - Sender implementation with error handling
  • src/services/nostr/handler.ts - Handler updates
  • src/services/main/debitManager.ts - Debit response logging
  • src/nostrMiddleware.ts - Middleware signature
  • src/services/storage/tlv/tlvFilesStorageProcessor.ts - Storage signature
  • src/services/webRTC/index.ts - WebRTC handler

Test Plan

  • Test ndebit claim flow with ShockWallet
  • Verify Kind 21002 response is sent and received
  • Check logs for event publishing status

🤖 Generated with Claude Code

## Summary Fixes an issue where ShockWallet would show "Debit request failed" even though the payment succeeded, because Lightning.Pub wasn't properly sending Kind 21002 responses back to the wallet. ### Problem The `NostrSend` type was incorrectly typed as returning `void` when it actually returns `Promise<void>`. This caused async errors to be silently swallowed when sending Kind 21002 (ndebit) responses. ### Solution 1. Update type signature to return `Promise<void>` 2. Add proper error handling with `.catch()` logging 3. Update all call sites to handle the async nature ## Commits 1. `fix(nostr): update NostrSend type to Promise<void> with error handling` 2. `fix(handlers): await NostrSend calls throughout codebase` ## Files Changed - `src/services/nostr/nostrPool.ts` - Type definition - `src/services/nostr/sender.ts` - Sender implementation with error handling - `src/services/nostr/handler.ts` - Handler updates - `src/services/main/debitManager.ts` - Debit response logging - `src/nostrMiddleware.ts` - Middleware signature - `src/services/storage/tlv/tlvFilesStorageProcessor.ts` - Storage signature - `src/services/webRTC/index.ts` - WebRTC handler ## Test Plan - [ ] Test ndebit claim flow with ShockWallet - [ ] Verify Kind 21002 response is sent and received - [ ] Check logs for event publishing status --- 🤖 Generated with [Claude Code](https://claude.com/code)
padreug added 2 commits 2026-01-25 19:39:28 +00:00
The NostrSend type was incorrectly typed as returning void when it actually
returns Promise<void>. This caused async errors to be silently swallowed.

Changes:
- Update NostrSend type signature to return Promise<void>
- Make NostrSender._nostrSend default to async function
- Add .catch() error handling in NostrSender.Send() to log failures
- Add logging to track event publishing status

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fix(handlers): await NostrSend calls throughout codebase
Some checks failed
Docker Compose Actions Workflow / test (push) Has been cancelled
748a2d3ed6
Update all NostrSend call sites to properly handle the async nature
of the function now that it returns Promise<void>.

Changes:
- handler.ts: Add async to sendResponse, await nostrSend calls
- debitManager.ts: Add logging for Kind 21002 response sending
- nostrMiddleware.ts: Update nostrSend signature
- tlvFilesStorageProcessor.ts: Update nostrSend signature
- webRTC/index.ts: Add async/await for nostrSend calls

This ensures Kind 21002 (ndebit) responses are properly sent to
wallet clients, fixing the "Debit request failed" issue in ShockWallet.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
padreug merged commit 748a2d3ed6 into dev 2026-01-25 19:39:55 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: aiolabs/lightning-pub#1
No description provided.