From a28c1130879681741eb065ec33f78b99010274ea Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Sun, 25 Jan 2026 17:44:45 -0500 Subject: [PATCH] fix: use correct Lightning.Pub pubkey and pointer in ndebit generation The ndebit must encode Lightning.Pub's pubkey (not the ATM's pubkey) so that Kind 21002 debit requests are received by Lightning.Pub. Also added the 'atm' pointer to identify which Lightning.Pub user account should pay the invoice. Fixes: - Changed pubkey from ATM identity to Lightning.Pub pubkey - Added pointer: 'atm' to ndebit encoding - Updated hardcoded pubkey to match current Lightning.Pub instance Co-Authored-By: Claude Opus 4.5 --- lamassu-next/apps/machine/src/services/lightning.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lamassu-next/apps/machine/src/services/lightning.ts b/lamassu-next/apps/machine/src/services/lightning.ts index 0eee1a3..f4b68ef 100644 --- a/lamassu-next/apps/machine/src/services/lightning.ts +++ b/lamassu-next/apps/machine/src/services/lightning.ts @@ -40,7 +40,7 @@ const LOCAL_IP = '192.168.1.122' // Change this to your machine's local IP const DEV_CONFIG = { // Lightning.Pub Nostr pubkey (from docker logs - check with: docker logs lamassu-lightning-pub | grep pubkey) - lightningPubPubkey: 'f454c5eec4ec4474128e19b57b45e49c3d0851d01eea960b39ce391cdba76fc6', + lightningPubPubkey: '4be8e203a3341bb2b74a4dcbf8774e061437f63ec21af7ec3144c8d0a68e2f39', // Local strfry relay - use local IP for cross-device testing relayUrl: `ws://${LOCAL_IP}:7777`, // Admin token for HTTP API (development only) @@ -202,10 +202,14 @@ function createATMServices( generateNdebit: async (context: ATMContext): Promise => { console.log('[ATM Service] Generating ndebit for', context.satsAmount, 'sats') - // Create ndebit with ATM's pubkey and relay + // Create ndebit with Lightning.Pub's pubkey (not ATM's pubkey!) + // The wallet sends Kind 21002 to the pubkey in the ndebit, + // so it must be Lightning.Pub's pubkey for it to receive and pay. + // The pointer identifies which Lightning.Pub user account pays (e.g., "atm") const ndebit = encodeNdebit({ - pubkey: _identity.publicKey, + pubkey: DEV_CONFIG.lightningPubPubkey, relay: DEV_CONFIG.relayUrl, + pointer: 'atm', // Lightning.Pub user identifier for the ATM account }) // Format as full URI with amount