feat: NIP-17 gift-wrapped check-in DM on confirmation (#5)

On settlement, send the guest their private check-in details as a NIP-59
gift-wrapped DM (nostr/giftwrap.py, built from lnbits core primitives — no
vendored crypto):

- rumor (kind 14) -> seal (kind 13, operator-encrypted + operator-signed via
  the signer abstraction) -> gift wrap (kind 1059, ephemeral-key encrypted +
  signed locally via core nip44_encrypt + sign_event). created_at randomised
  into the past per NIP-59.
- service.send_checkin_dm builds the message (room.checkin_instructions +
  settings times/policy) and publishes via nostrclient (_publish_signed,
  extracted from _sign_and_publish).
- tasks.on_invoice_paid calls it best-effort — a DM failure never undoes a
  confirmed, paid booking.

Encrypted layer (seal) soft-fails on a LocalSigner until bunker/server-
signing (lnbits#18), same as the reservation event; the ephemeral wrap layer
always works.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019VUQCfdqiLSsFS2jcGnaFD
This commit is contained in:
Padreug 2026-07-19 20:34:12 +02:00
commit b6ca1b0e02
3 changed files with 166 additions and 3 deletions

View file

@ -42,8 +42,17 @@ async def on_invoice_paid(payment: Payment):
await crud.update_booking(booking)
booking.reservation_event_id = await nostr.publish_reservation(booking)
await crud.update_booking(booking)
# TODO(checkin): DM check-in details (address, gate code, times) to the
# guest via NIP-17 giftwrap once relay plumbing lands.
# Send the guest their private check-in details (NIP-17 gift-wrapped DM).
# Best-effort: a publish failure must not undo a confirmed, paid booking.
try:
room = await crud.get_room(booking.room_id)
settings = await crud.get_or_create_settings()
if room:
await nostr.send_checkin_dm(booking, room, settings)
except Exception as exc: # noqa: BLE001
logger.warning(f"chatelet: check-in DM failed for {booking.id} (continuing): {exc}")
logger.info(f"chatelet: booking {booking.id} confirmed")