feat: events_ticket_register RPC over nostr transport
Organizer-side ticket scanning over LNbits's freshly-merged nostr-transport (kind 21000, NIP-44 v2). The organizer signs the RPC event with their Nostr key; the transport dispatcher resolves pubkey → Account → wallet (AUTH_WALLET) and the handler verifies event-level ownership (event.wallet ∈ caller_user.wallet_ids) before flipping `registered = True`. Idempotence + state transitions mirror the legacy HTTP endpoint: "Ticket not paid for" / "Ticket already registered" / "Ticket does not exist on this event" / "You do not own this event" come back as ERROR responses. Registration in events_start() is guarded with try/except ImportError so the extension still loads on older LNbits versions that pre-date the transport (HTTP path stays the fallback there). Webapp uses this as the new primary scan call site instead of the legacy HTTP endpoint — see companion webapp PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7b761a1aef
commit
2b3d9df11d
2 changed files with 89 additions and 0 deletions
21
__init__.py
21
__init__.py
|
|
@ -46,6 +46,27 @@ def events_start():
|
|||
task1 = create_permanent_unique_task("ext_events", wait_for_paid_invoices)
|
||||
scheduled_tasks.append(task1)
|
||||
|
||||
# Register nostr-transport RPCs. Swallow ImportError on older LNbits
|
||||
# versions that pre-date the transport (the events extension still
|
||||
# works fine via HTTP without it).
|
||||
try:
|
||||
from lnbits.core.services.nostr_transport.dispatcher import (
|
||||
AUTH_WALLET,
|
||||
register_rpc,
|
||||
)
|
||||
|
||||
from .transport_rpcs import handle_events_ticket_register
|
||||
|
||||
register_rpc(
|
||||
"events_ticket_register", handle_events_ticket_register, AUTH_WALLET
|
||||
)
|
||||
logger.info("[EVENTS] Registered nostr-transport RPC: events_ticket_register")
|
||||
except ImportError:
|
||||
logger.info(
|
||||
"[EVENTS] nostr_transport not available on this LNbits — "
|
||||
"ticket scanner over Nostr disabled, HTTP endpoint still works"
|
||||
)
|
||||
|
||||
async def _start_nostr_client():
|
||||
global nostr_client
|
||||
await asyncio.sleep(10) # Wait for nostrclient to be ready
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue