Skip to content

Commit

Permalink
Bug fix: Open offers
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahanaFarooqui committed Nov 23, 2023
1 parent db81df1 commit 59b35c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion backend/controllers/cln/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export const postPayment = (req, res, next) => {
else {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Sending Invoice Payment..' });
}
if (req.body.paymentType === 'OFFER') {
// delete amount for zero amt offer also as fetchinvoice already has amount information
delete options_body.amount_msat;
}
delete options_body.uiMessage;
delete options_body.fromDialog;
delete options_body.paymentType;
Expand All @@ -145,7 +149,7 @@ export const postPayment = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Sent', data: body });
if (req.body.paymentType === 'OFFER') {
if (req.body.saveToDB && req.body.bolt12) {
const offerToUpdate = { bolt12: req.body.bolt12, amountMSat: (req.body.zeroAmtOffer ? 0 : req.body.amount), title: req.body.title, lastUpdatedAt: new Date(Date.now()).getTime() };
const offerToUpdate = { bolt12: req.body.bolt12, amountMSat: (req.body.zeroAmtOffer ? 0 : req.body.amount_msat), title: req.body.title, lastUpdatedAt: new Date(Date.now()).getTime() };
if (req.body.issuer) {
offerToUpdate['issuer'] = req.body.issuer;
}
Expand Down
6 changes: 5 additions & 1 deletion server/controllers/cln/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export const postPayment = (req, res, next) => {
} else {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Sending Invoice Payment..' });
}
if (req.body.paymentType === 'OFFER') {
// delete amount for zero amt offer also as fetchinvoice already has amount information
delete options_body.amount_msat;
}
delete options_body.uiMessage;
delete options_body.fromDialog;
delete options_body.paymentType;
Expand All @@ -135,7 +139,7 @@ export const postPayment = (req, res, next) => {
logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Payments', msg: 'Payment Sent', data: body });
if (req.body.paymentType === 'OFFER') {
if (req.body.saveToDB && req.body.bolt12) {
const offerToUpdate: Offer = { bolt12: req.body.bolt12, amountMSat: (req.body.zeroAmtOffer ? 0 : req.body.amount), title: req.body.title, lastUpdatedAt: new Date(Date.now()).getTime() };
const offerToUpdate: Offer = { bolt12: req.body.bolt12, amountMSat: (req.body.zeroAmtOffer ? 0 : req.body.amount_msat), title: req.body.title, lastUpdatedAt: new Date(Date.now()).getTime() };
if (req.body.issuer) { offerToUpdate['issuer'] = req.body.issuer; }
if (req.body.description) { offerToUpdate['description'] = req.body.description; }
// eslint-disable-next-line arrow-body-style
Expand Down

0 comments on commit 59b35c6

Please sign in to comment.