diff --git a/dist/src/controllers/invoices.js b/dist/src/controllers/invoices.js index 684c4a259..9b6e65cc2 100644 --- a/dist/src/controllers/invoices.js +++ b/dist/src/controllers/invoices.js @@ -240,12 +240,24 @@ function getInvoice(req, res) { if (!req.owner) return (0, res_1.failure)(res, 'no owner'); const payment_request = req.query.payment_request; - if (!payment_request) { - return (0, res_1.failure)(res, 'Invalid payment request'); + let payment_hash = req.query.payment_hash; + if (!payment_request && !payment_hash) { + return (0, res_1.failure)(res, 'No payment request or hash'); + } + if (!payment_hash) { + try { + const decodedPaymentRequest = bolt11.decode(payment_request); + payment_hash = + ((_a = decodedPaymentRequest.tags.find((t) => t.tagName === 'payment_hash')) === null || _a === void 0 ? void 0 : _a.data) || ''; + } + catch (e) { + return (0, res_1.failure)(res, e); + } + } + if (!payment_hash) { + return (0, res_1.failure)(res, 'No payment hash'); } try { - const decodedPaymentRequest = bolt11.decode(payment_request); - const payment_hash = ((_a = decodedPaymentRequest.tags.find((t) => t.tagName === 'payment_hash')) === null || _a === void 0 ? void 0 : _a.data) || ''; const invoice = yield Lightning.getInvoiceHandler(payment_hash, req.owner.publicKey); return (0, res_1.success)(res, invoice); } diff --git a/dist/src/controllers/invoices.js.map b/dist/src/controllers/invoices.js.map index e9463c87e..b0c0c1fb4 100644 --- a/dist/src/controllers/invoices.js.map +++ b/dist/src/controllers/invoices.js.map @@ -1 +1 @@ -{"version":3,"file":"invoices.js","sourceRoot":"","sources":["../../../src/controllers/invoices.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAmC;AACnC,wCAAuC;AAEvC,sCAA6D;AAC7D,+CAA8C;AAE9C,0CAAyC;AACzC,2CAA0C;AAC1C,4CAAsD;AACtD,sCAAqC;AACrC,gCAAyC;AACzC,sCAAoE;AACpE,sCAAqC;AAErC,4CAAoC;AACpC,4CAA8C;AAG9C,mDAAkD;AAElD,SAAS,oBAAoB,CAAC,CAAS;IACrC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,UAAU,C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G,MAAM,CAAA;IAC/B,MAAM,OAAO,GAAG,SAAS,KAAK,mBAAS,CAAC,UAAU,CAAC,KAAK,CAAA;IACxD,IAAI,OAAO,EAAE;QACX,GAAG,CAAC,WAAW,GAAG,YAAY,CAAA;QAC9B,GAAG,CAAC,SAAS,GAAG,gBAAgB,CAAA;KACjC;IACD,MAAM,OAAO,GAAkB,CAAC,MAAM,eAAM,CAAC,OAAO,CAAC,MAAM,CACzD,GAAG,CACJ,CAAkB,CAAA;IACnB,qBAAY,CAAC,IAAI,CAAC,oCAAoC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAEnE,MAAM,CAAC,QAAQ,CACb;QACE,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC;KACzD,EACD,MAAM,CACP,CAAA;IAED,IAAA,sBAAgB,EAAC,IAAI,EAAE,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;IAEzE,IAAA,gCAAgB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;AACrE,CAAC,CAAA,CAAA;AAtEY,QAAA,cAAc,kBAsE1B"} \ No newline at end of file +{"version":3,"file":"invoices.js","sourceRoot":"","sources":["../../../src/controllers/invoices.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAmC;AACnC,wCAAuC;AAEvC,sCAA6D;AAC7D,+CAA8C;AAE9C,0CAAyC;AACzC,2CAA0C;AAC1C,4CAAsD;AACtD,sCAAqC;AACrC,gCAAyC;AACzC,sCAAoE;AACpE,sCAAqC;AAErC,4CAAoC;AACpC,4CAA8C;AAG9C,mDAAkD;AAElD,SAAS,oBAAoB,CAAC,CAAS;IACrC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;QAA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cAAc,EAAE,IAAI,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC;QACzD,IAAI,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC;QAC3B,MAAM,EAAE,mBAAS,CAAC,QAAQ,CAAC,OAAO;QAClC,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,YAAY;QAC1B,MAAM;KACP,CAAA;IACD,IAAI,MAAM;QAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;IAC/B,MAAM,OAAO,GAAG,SAAS,KAAK,mBAAS,CAAC,UAAU,CAAC,KAAK,CAAA;IACxD,IAAI,OAAO,EAAE;QACX,GAAG,CAAC,WAAW,GAAG,YAAY,CAAA;QAC9B,GAAG,CAAC,SAAS,GAAG,gBAAgB,CAAA;KACjC;IACD,MAAM,OAAO,GAAkB,CAAC,MAAM,eAAM,CAAC,OAAO,CAAC,MAAM,CACzD,GAAG,CACJ,CAAkB,CAAA;IACnB,qBAAY,CAAC,IAAI,CAAC,oCAAoC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAEnE,MAAM,CAAC,QAAQ,CACb;QACE,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC;KACzD,EACD,MAAM,CACP,CAAA;IAED,IAAA,sBAAgB,EAAC,IAAI,EAAE,GAAG,CAAC,WAAW,IAAI,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;IAEzE,IAAA,gCAAgB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;AACrE,CAAC,CAAA,CAAA;AAtEY,QAAA,cAAc,kBAsE1B"} \ No newline at end of file diff --git a/src/controllers/invoices.ts b/src/controllers/invoices.ts index ed363c2ed..7ea5dfe65 100644 --- a/src/controllers/invoices.ts +++ b/src/controllers/invoices.ts @@ -258,15 +258,25 @@ export const listInvoices = async (req: Req, res: Response): Promise => { export async function getInvoice(req: Req, res: Response): Promise { if (!req.owner) return failure(res, 'no owner') const payment_request = req.query.payment_request as string + let payment_hash = req.query.payment_hash as string - if (!payment_request) { - return failure(res, 'Invalid payment request') + if (!payment_request && !payment_hash) { + return failure(res, 'No payment request or hash') + } + if (!payment_hash) { + try { + const decodedPaymentRequest = bolt11.decode(payment_request) + payment_hash = + (decodedPaymentRequest.tags.find((t) => t.tagName === 'payment_hash') + ?.data as string) || ('' as string) + } catch (e) { + return failure(res, e) + } + } + if (!payment_hash) { + return failure(res, 'No payment hash') } try { - const decodedPaymentRequest = bolt11.decode(payment_request) - const payment_hash = - (decodedPaymentRequest.tags.find((t) => t.tagName === 'payment_hash') - ?.data as string) || ('' as string) const invoice = await Lightning.getInvoiceHandler( payment_hash, req.owner.publicKey