@@ -185,17 +185,27 @@ const generateLnurlAuth = async (query) => {
185185} ;
186186
187187const generateBolt11 = async ( query ) => {
188- const { amount } = query ;
188+ const { amount, amount_msat } = query ;
189189
190- // Default to 0 (zero-amount invoice) if not specified
191- const amountSats = amount ? parseInt ( amount ) : 0 ;
190+ let invoice ;
191+ let amountDisplay ;
192192
193- if ( isNaN ( amountSats ) || amountSats < 0 ) {
194- throw new ValidationError ( 'Invalid amount. Must be zero or a positive integer.' ) ;
193+ if ( amount_msat ) {
194+ const msat = parseInt ( amount_msat ) ;
195+ if ( isNaN ( msat ) || msat < 0 ) {
196+ throw new ValidationError ( 'Invalid amount_msat. Must be zero or a positive integer.' ) ;
197+ }
198+ invoice = await lndService . createInvoiceMsat ( msat , '' , 3600 ) ;
199+ amountDisplay = { msat } ;
200+ } else {
201+ const amountSats = amount ? parseInt ( amount ) : 0 ;
202+ if ( isNaN ( amountSats ) || amountSats < 0 ) {
203+ throw new ValidationError ( 'Invalid amount. Must be zero or a positive integer.' ) ;
204+ }
205+ invoice = await lndService . createInvoice ( amountSats , '' , 3600 ) ;
206+ amountDisplay = { sats : amountSats } ;
195207 }
196208
197- // Create invoice with LND
198- const invoice = await lndService . createInvoice ( amountSats , '' , 3600 ) ;
199209 const paymentRequest = invoice . payment_request ;
200210
201211 const qrCode = await QRCode . toDataURL ( paymentRequest , {
@@ -207,13 +217,13 @@ const generateBolt11 = async (query) => {
207217 }
208218 } ) ;
209219
210- Logger . info ( 'Bolt11 invoice generated' , { amount : amountSats , paymentHash : invoice . r_hash } ) ;
220+ Logger . info ( 'Bolt11 invoice generated' , { amount : amountDisplay , paymentHash : invoice . r_hash } ) ;
211221
212222 return {
213223 bolt11 : paymentRequest ,
214224 qrCode,
215225 type : 'bolt11' ,
216- amount : amountSats ,
226+ amount : amountDisplay ,
217227 paymentHash : invoice . r_hash
218228 } ;
219229} ;
0 commit comments