Nip47 notifications#30
Conversation
d285107 to
540f9e8
Compare
- Auto-format with black, ruff --fix, prettier - Fix ruff C901: extract _notify_payment_sent helper to reduce complexity - Fix ruff RUF059: prefix unused unpacked variable with underscore - Add noqa: E402 for intentional late imports in standalone test mocks - Fix pyright: add None guard on payment_status.success - Fix mock parameter names to match send_notification signature
Standalone notification tests use heavy sys.modules patching to run without lnbits installed. Exclude them from mypy/pyright since static type checking cannot follow dynamic module injection. Also add type ignore for optional lnurlp extension import.
Standalone test files with sys.modules mocking cause mypy "found twice" errors when in the main package tree. Moving to tests/standalone/ (no __init__.py) prevents mypy from discovering them as package modules. Also update pyright exclude and fix PROJECT_DIR paths.
- Re-run black/ruff/prettier after rebase - Move standalone tests to tests/standalone/ (no __init__.py) to prevent mypy "found twice" module discovery conflict - Exclude tests/standalone/ from mypy and pyright - Fix PROJECT_DIR paths for new location
1324bd0 to
c333590
Compare
Our lock had mypy 1.19.1 which crashes on pydantic v1 env_settings. Main uses mypy 1.17.1 which works correctly.
Adding pyrightconfig.json changed pyright's project resolution, causing it to scan node_modules typeshed stubs. Without the config file, pyright uses the lnbits shared CI workflow defaults which work.
These files use heavy sys.modules patching that pyright cannot follow. Inline directives suppress the expected errors without needing a pyrightconfig.json (which changes pyright's project resolution).
The pairing URL now encodes the relay with quote(), but the test NWCWallet client was using the encoded value directly to connect, causing 'scheme isn't ws or wss' errors.
|
subbed |
|
I support this PR to provide the most robust LNbits NIP support possible to keep pace with Nostr's robust growth. This also compliments #38 and lnbits/nostrrelay#44 for LNbits Nostr Relay extension, fixing a patch of NostrClient as current gap within the platform for Nostr for LNBits Paid Relays needed for AI agents to subscribe to a subdomains and charge each agent user (assuming all PRs are implemented)
With all PR's implemented, the LNbits platform can finally boast a robust, modern Nostr Relay / NWC Provider pairing for the Agent AI Economy |
|
I'm not familiar with NWC! Can you please add some testing steps so i can test it? |
|
Hey @talvasconcelos, one way to test:
You can verify directly on the relay by watching for kind |
|
didn't fully tested, but it seems to do what it intends to do |
- resolve tasks.py conflict (align with upstream lnbits#43) - restore poetry.lock
Closer the gap vs. WoS by polling the SPECIFIC invoice's settled state via NIP-47 \`lookup_invoice\` rather than polling wallet-wide balance: - LNbits flips \`settled_at\` the instant LND signals settle — no wait for balance aggregation / cache propagation. - Targeted request (one invoice) vs. balance roll-up (full wallet totals) — lighter and less prone to slow responses on busy backends. - On settle, fall through to a one-shot \`refreshBalanceForWallet\` call so the WalletContext diff-detector still fires the overlay — single source of truth for "balance went up ⇒ celebrate". - Poll cadence tightened 1500 ms → 1000 ms (lookup_invoice is a lighter request than get_balance on most backends). - Fallback to balance polling retained for the rare case where the bolt11 doesn't yield an extractable payment_hash. Remaining gap vs. WoS is architectural: WoS talks to its own LN node directly with push/subscription; we go through LNbits + NWC + a Nostr relay, so there's always some round-trip floor. The remaining cure-all is NIP-47 notifications (tracked: lnbits/nwcprovider#30). Also restrict amount inputs in Send and Receive sheets to digits only (sats) or digits + single decimal (fiat). Hardware keyboards, paste, and autocomplete can bypass the soft-keyboard numeric hint and inject junk characters that caused silent "Invalid amount" rejections. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Added support for it.
Its the part of nwc service provider extension.
nwc funding source needs it in addition to support the spec as well and reduce potential load on server. Requested here:
lnbits/lnbits#3187