Merge branch 'master' into feature/secrets_storage

This commit is contained in:
emad-salah 2020-08-17 15:25:26 +01:00
commit 4718305547

View file

@ -591,13 +591,15 @@ module.exports = async (
logger.error('Channel backup stream error:', err) logger.error('Channel backup stream error:', err)
}) })
stream.on('status', status => { stream.on('status', status => {
logger.error('Channel backup stream status:', status)
if (status.code === 14) { if (status.code === 14) {
// Prevents call stack overflow exceptions // Prevents call stack overflow exceptions
process.nextTick(onNewChannelBackup) process.nextTick(() => setTimeout(onNewChannelBackup, 30000))
} else {
logger.error('Channel backup stream status:', status)
} }
}) })
} }
onNewChannelBackup() onNewChannelBackup()
// Generate auth token and send it as a JSON response // Generate auth token and send it as a JSON response
@ -1471,7 +1473,8 @@ module.exports = async (
}, },
payment_hash: r_hash, payment_hash: r_hash,
max_parts: maxParts, max_parts: maxParts,
timeout_seconds: timeoutSeconds timeout_seconds: timeoutSeconds,
no_inflight_updates: true
} }
} else { } else {
const { payreq } = req.body const { payreq } = req.body
@ -1479,7 +1482,8 @@ module.exports = async (
paymentRequest = { paymentRequest = {
payment_request: payreq, payment_request: payreq,
max_parts: maxParts, max_parts: maxParts,
timeout_seconds: timeoutSeconds timeout_seconds: timeoutSeconds,
no_inflight_updates: true
} }
if (req.body.amt) { if (req.body.amt) {
@ -1493,17 +1497,17 @@ module.exports = async (
sentPayment.on('data', response => { sentPayment.on('data', response => {
if (res.headersSent) { if (res.headersSent) {
//if res was already sent //if res was already sent
if (response.failure_reason !== 'FAILURE_REASON_NONE') { if (response.status !== 'SUCCEEDED') {
//if the operation failed //if the operation failed
finalEvent = { error: response.failure_reason } logger.error('Sen payment failure', response.details)
} else { } else {
finalEvent = { status: response.status } finalEvent = { status: response.status }
} }
} else { } else {
if (response.failure_reason !== 'FAILURE_REASON_NONE') { if (response.status !== 'SUCCEEDED') {
logger.error('SendPayment Info:', response) logger.error('Sen payment failure', response.details)
return res.status(500).json({ return res.status(500).json({
errorMessage: response.failure_reason errorMessage: sanitizeLNDError(response.details)
}) })
} }
logger.info('SendPayment Data:', response) logger.info('SendPayment Data:', response)
@ -1518,12 +1522,12 @@ module.exports = async (
sentPayment.on('error', async err => { sentPayment.on('error', async err => {
logger.error('SendPayment Error:', err) logger.error('SendPayment Error:', err)
if (res.headersSent) { if (res.headersSent) {
finalEvent = { error: err.details } //send error on socket if http has already finished logger.error('Sen payment failure', err)
} else { } else {
const health = await checkHealth() const health = await checkHealth()
if (health.LNDStatus.success) { if (health.LNDStatus.success) {
res.status(500).json({ res.status(500).json({
errorMessage: sanitizeLNDError(err.details) errorMessage: sanitizeLNDError(err)
}) })
} else { } else {
res.status(500) res.status(500)