Feature: NIP-17 order intake transport (gift-wrapped DMs) #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
Order placement today is REST: customer webapp posts to
POST /restaurant/api/v1/orders, restaurant LNbits responds with abolt11. The longer-term direction (per
/etc/nixos/modules/dev-env/docs/stack-overview.md's "Futuredirection: Nostr-native transport" section) is to move
inter-service communication onto signed Nostr events as RPC.
For ordering, that means NIP-17 gift-wrapped DMs (kind 1059 →
kind 14 unwrap via NIP-44 v2). References:
~/dev/refs/repos/nostr-protocol/nips/17.md,~/dev/refs/repos/nostr-protocol/nips/44.md.The extension already has the dispatcher scaffolded —
nostr_sync._place_order_from_dmis complete and wired behind asettings flag (
settings.nostr_orders_enabled). What's missing is(a) the NIP-44 v2 unwrap on the extension side and (b) the NIP-44
wrap + signing on the webapp side.
The customer webapp's v1 ships REST-only to keep that path
fast; this issue tracks the additive Nostr-native transport for v2.
Goals
Extension side
(kind 13) and re-unwrap of the rumor (kind 14) inside
nostr_sync._handle_gift_wrapped_dm._place_order_from_dmhelperunchanged.
NIP-17 DMs (
paid → accepted → ready → delivered).settings.nostr_orders_enabledgates the listener; flagdocumented in
docs/nostr-layer.md.event.idto prevent thesame DM from re-creating an order if a relay re-delivers.
Webapp side
AuthServiceso we can sign customer events without holding theuser's nsec in webapp memory. Detect
window.nostr, prompt onfirst use, sign via the extension.
transport: 'rest' | 'nostr'option, default
rest.nostr, the cart'sCreateOrderpayload is gift-wrapped tothe restaurant's
nostr_pubkeyand published; the webappsubscribes for the response DM carrying the bolt11; payment then
flows through the same
WalletService.payInvoiceas the RESTpath.
Open design questions
NIP-07 (browser extension), NIP-46 (remote signer / nsec.app),
or webapp-generated and stored encrypted in localStorage? Today
the webapp's
AuthServicecachesaccount.prvkeyfrom theLNbits account record — that is not acceptable as a
long-term solution; v1 of NIP-17 should require NIP-07.
separate request/response convention? NIP-17 is one-way DM
semantically; restaurants need to write back. Probably a matched
DM with
["e", <customer_request_event_id>]as a thread tag.several seconds. UX needs an interim "Submitting…" state with a
reasonable timeout.
this is additive. Operators may want it for non-Nostr customers
(kiosks, web fallback).
Acceptance criteria
Extension
nostr_sync._handle_gift_wrapped_dmperforms full NIP-44 v2unwrap and dispatches to
_place_order_from_dm.customer pubkey (
paid → accepted → ready → delivered).settings.nostr_orders_enabledgates the listener; flagdocumented in
docs/nostr-layer.md.event.id.status DM emission.
Webapp
AuthService(detectwindow.nostr, prompt, sign).useCheckout()gains atransport: 'rest' | 'nostr'option; default
rest.nostr, the cart'sCreateOrderis gift-wrapped tothe restaurant pubkey and published; webapp subscribes for
the response DM carrying the bolt11; payment then flows
through the same
WalletService.payInvoice.docs/webapp-integration.mdand the extension'sdocs/nostr-layer.mdboth gain the live (not-stubbed)NIP-17 flow description.
Out of scope
support).
customers (kiosks, web fallback).
Files / surfaces
Extension:
~/dev/shared/extensions/restaurant/nostr_sync.py~/dev/shared/extensions/restaurant/nostr_publisher.py~/dev/shared/extensions/restaurant/nostr/event.py~/dev/shared/extensions/restaurant/services.py(status-transition hook for outbound DMs)
~/dev/shared/extensions/restaurant/docs/nostr-layer.mdWebapp:
~/dev/webapp/src/modules/base/auth/auth-service.ts~/dev/webapp/src/modules/base/nostr/relay-hub.ts(if it needspublishing helpers it doesn't already expose)
~/dev/webapp/src/modules/restaurant/composables/useCheckout.ts~/dev/webapp/src/modules/restaurant/services/RestaurantNostrSync.tsSee also
native trajectory)
venue accepts Nostr-DM orders at all)
References
~/dev/refs/repos/nostr-protocol/nips/17.md~/dev/refs/repos/nostr-protocol/nips/44.mdat
/etc/nixos/modules/dev-env/docs/stack-overview.md