diff --git a/lamassu-next/apps/machine/src/services/lightning.ts b/lamassu-next/apps/machine/src/services/lightning.ts index e9cdeb0..811bccf 100644 --- a/lamassu-next/apps/machine/src/services/lightning.ts +++ b/lamassu-next/apps/machine/src/services/lightning.ts @@ -828,19 +828,12 @@ function createATMServices( /** * Get current exchange rate + * TODO: Fetch from Lightning.Pub or external price feed */ getExchangeRate: async (currency: string): Promise => { - console.log('[ATM Service] Fetching exchange rate for', currency) - - try { - const rate = await lightningPub.getExchangeRate(currency) - console.log('[ATM Service] Exchange rate:', rate.satsPerUnit, 'sats/' + currency) - return rate.satsPerUnit - } catch (error) { - console.warn('[ATM Service] Failed to fetch rate, using fallback:', error) - // Fallback rate for development - return 2500 // sats per USD (~$40k BTC) - } + console.log('[ATM Service] Using fixed exchange rate for', currency) + // Fixed rate for development/testing + return 1000 // sats per USD (~$100k BTC) }, /** diff --git a/lamassu-next/apps/machine/src/stores/atm.ts b/lamassu-next/apps/machine/src/stores/atm.ts index 7eb229f..6d472a2 100644 --- a/lamassu-next/apps/machine/src/stores/atm.ts +++ b/lamassu-next/apps/machine/src/stores/atm.ts @@ -41,7 +41,7 @@ const mockServices: ATMServices = { getExchangeRate: async (currency) => { console.log('[Mock] Fetching exchange rate for', currency) - return 2500 + return 1000 // 1000 sats per USD (~$100k BTC) }, sendNostrReceipt: async (context) => { diff --git a/lamassu-next/packages/state-machine/src/__tests__/machine.test.ts b/lamassu-next/packages/state-machine/src/__tests__/machine.test.ts index 7f9eff6..e13ee96 100644 --- a/lamassu-next/packages/state-machine/src/__tests__/machine.test.ts +++ b/lamassu-next/packages/state-machine/src/__tests__/machine.test.ts @@ -75,7 +75,7 @@ describe('ATM State Machine', () => { const context = actor.getSnapshot().context expect(context.billsInserted).toEqual([20, 10]) - expect(context.fiatAmount).toBe(30) // $30 in cents? No, as dollars + expect(context.fiatAmount).toBe(3000) // $30 in cents }) it('should return to idle on CANCEL', async () => { diff --git a/lamassu-next/packages/state-machine/src/machine.ts b/lamassu-next/packages/state-machine/src/machine.ts index 68fac20..480f741 100644 --- a/lamassu-next/packages/state-machine/src/machine.ts +++ b/lamassu-next/packages/state-machine/src/machine.ts @@ -145,7 +145,8 @@ export function createATMMachine(services: Partial = {}) { }, fiatAmount: ({ context, event }) => { if (event.type !== 'BILL_INSERTED') return context.fiatAmount - return context.fiatAmount + event.denomination + // denomination is in dollars, fiatAmount is in cents + return context.fiatAmount + event.denomination * 100 }, }), calculateSats: assign({