diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 04324207..062f0f24 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -924,6 +924,7 @@ const sendHRWithInitialMsg = async ( * @typedef {object} SpontPaymentOptions * @prop {Common.Schema.OrderTargetType} type * @prop {string=} postID + * @prop {string=} ackInfo */ /** diff --git a/src/routes.js b/src/routes.js index f61a4857..a79b5eb7 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1192,12 +1192,35 @@ module.exports = async ( app.post('/api/lnd/unifiedTrx', async (req, res) => { try { - const { type, amt, to, memo, feeLimit, postID } = req.body + const { type, amt, to, memo, feeLimit, postID, ackInfo } = req.body - if (type !== 'spont' && type !== 'post') { + if ( + type !== 'spont' && + type !== 'post' && + type !== 'spontaneousPayment' && + type !== 'tip' && + type !== 'torrentSeed' && + type !== 'contentReveal' && + type !== 'other' + ) { return res.status(415).json({ field: 'type', - errorMessage: `Only 'spont' and 'post' payments supported via this endpoint for now.` + errorMessage: `Only 'spontaneousPayment'| 'tip' | 'torrentSeed' | 'contentReveal' | 'other' payments supported via this endpoint for now.` + }) + } + + const typesThatShouldContainAckInfo = [ + 'tip', + 'torrentSeed', + 'contentReveal' + ] + + const shouldContainAckInfo = typesThatShouldContainAckInfo.includes(type) + + if (shouldContainAckInfo && !Common.isPopulatedString(ackInfo)) { + return res.status(400).json({ + field: 'ackInfo', + errorMessage: `Transactions of type ${typesThatShouldContainAckInfo} should contain an ackInfo field.` }) } @@ -1241,7 +1264,8 @@ module.exports = async ( return res.status(200).json( await GunActions.sendSpontaneousPayment(to, amt, memo, feeLimit, { type, - postID + postID, + ackInfo }) ) } catch (e) {