validation

This commit is contained in:
Daniel Lugo 2020-08-21 14:55:43 -04:00
parent 5532fbdb0f
commit 54bf1197e2
2 changed files with 20 additions and 2 deletions

View file

@ -1190,6 +1190,20 @@ module.exports = async (
}) })
} }
if (!isARealUsableNumber(feeLimit)) {
return res.status(400).json({
field: 'feeLimit',
errorMessage: 'Not an usable number'
})
}
if (feeLimit < 1) {
return res.status(400).json({
field: 'feeLimit',
errorMessage: 'Must be 1 or greater.'
})
}
return res return res
.status(200) .status(200)
.json(await GunActions.sendSpontaneousPayment(to, amt, memo, feeLimit)) .json(await GunActions.sendSpontaneousPayment(to, amt, memo, feeLimit))

View file

@ -284,7 +284,9 @@ const sendPaymentV2Keysend = params => {
} = params } = params
if (!isValidSendPaymentKeysendParams(params)) { if (!isValidSendPaymentKeysendParams(params)) {
throw new TypeError('Invalid SendPaymentKeysendParams') throw new TypeError(
`Invalid SendPaymentKeysendParams: ${JSON.stringify(params)}`
)
} }
const preimage = Crypto.randomBytes(32) const preimage = Crypto.randomBytes(32)
@ -321,7 +323,9 @@ const sendPaymentV2Invoice = params => {
} = params } = params
if (!isValidSendPaymentInvoiceParams(params)) { if (!isValidSendPaymentInvoiceParams(params)) {
throw new TypeError('Invalid SendPaymentInvoiceParams') throw new TypeError(
`Invalid SendPaymentInvoiceParams: ${JSON.stringify(params)}`
)
} }
return sendPaymentV2({ return sendPaymentV2({