wire up transaction endpooint
This commit is contained in:
parent
6b86ab34a3
commit
6bdb660048
2 changed files with 29 additions and 4 deletions
|
|
@ -924,6 +924,7 @@ const sendHRWithInitialMsg = async (
|
||||||
* @typedef {object} SpontPaymentOptions
|
* @typedef {object} SpontPaymentOptions
|
||||||
* @prop {Common.Schema.OrderTargetType} type
|
* @prop {Common.Schema.OrderTargetType} type
|
||||||
* @prop {string=} postID
|
* @prop {string=} postID
|
||||||
|
* @prop {string=} ackInfo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1192,12 +1192,35 @@ module.exports = async (
|
||||||
|
|
||||||
app.post('/api/lnd/unifiedTrx', async (req, res) => {
|
app.post('/api/lnd/unifiedTrx', async (req, res) => {
|
||||||
try {
|
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({
|
return res.status(415).json({
|
||||||
field: 'type',
|
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(
|
return res.status(200).json(
|
||||||
await GunActions.sendSpontaneousPayment(to, amt, memo, feeLimit, {
|
await GunActions.sendSpontaneousPayment(to, amt, memo, feeLimit, {
|
||||||
type,
|
type,
|
||||||
postID
|
postID,
|
||||||
|
ackInfo
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue