diff --git a/src/handlers/lnurl.ts b/src/handlers/lnurl.ts index aa5eb72..2fb43a6 100644 --- a/src/handlers/lnurl.ts +++ b/src/handlers/lnurl.ts @@ -107,10 +107,17 @@ export function createLnurlHandlers(deps: LnurlHandlerDeps) { try { // Request a quote from the mint selected by this recipient. const wallet = await deps.walletProvider.getWallet(claim.mint_url); - const quote = await wallet.createMintQuoteBolt11( - Math.floor(amount / 1000), // Convert msats to sats - zapRequest?.raw, - ); + const amountSat = Math.floor(amount / 1000); + const quote = zapRequest + ? await wallet.mint.createMintQuoteBolt11({ + amount: amountSat, + unit: "sat", + description: zapRequest.raw, + description_hash: true, + } as Parameters[0] & { + description_hash: true; + }) + : await wallet.createMintQuoteBolt11(amountSat); let quoteExpiry = quote.expiry; if (zapRequest) { diff --git a/tests/per-recipient-mint.test.mjs b/tests/per-recipient-mint.test.mjs index 11a2b4b..e0db8f8 100644 --- a/tests/per-recipient-mint.test.mjs +++ b/tests/per-recipient-mint.test.mjs @@ -289,7 +289,7 @@ test("LNURL discovery advertises NIP-57 only when a zap signer is configured", a assert.equal(zapResult.data.nostrPubkey, zapPubkey); }); -test("a valid NIP-57 request becomes the mint invoice description", async (t) => { +test("a valid NIP-57 request asks the mint for a description hash", async (t) => { const db = createTestDatabase(t); const recipientPubkey = getPublicKey(generateSecretKey()); const senderSecretKey = generateSecretKey(); @@ -307,14 +307,24 @@ test("a valid NIP-57 request becomes the mint invoice description", async (t) => walletProvider: { async getWallet() { return { - async createMintQuoteBolt11(amount, description) { - assert.equal(amount, 21); - descriptions.push(description); - return { - quote: "zap-quote", - request: createTestInvoice(amount * 1_000, description), - expiry: null, - }; + mint: { + async createMintQuoteBolt11(payload) { + assert.deepEqual(payload, { + amount: 21, + unit: "sat", + description: rawZapRequest, + description_hash: true, + }); + descriptions.push(payload.description); + return { + quote: "zap-quote", + request: createTestInvoice( + payload.amount * 1_000, + payload.description, + ), + expiry: null, + }; + }, }, }; }, @@ -372,12 +382,14 @@ test("a zap invoice that does not commit to the request is rejected", async (t) walletProvider: { async getWallet() { return { - async createMintQuoteBolt11() { - return { - quote: "bad-zap-quote", - request: createTestInvoice(1_000, "not the zap request"), - expiry: 2_000_000_000, - }; + mint: { + async createMintQuoteBolt11() { + return { + quote: "bad-zap-quote", + request: createTestInvoice(1_000, "not the zap request"), + expiry: 2_000_000_000, + }; + }, }, }; },