update balance limit error msg
This commit is contained in:
parent
86cdb69082
commit
f438b14df7
|
@ -3,7 +3,8 @@ import retry from 'async-retry'
|
||||||
import Prisma from '@prisma/client'
|
import Prisma from '@prisma/client'
|
||||||
import { settleHodlInvoice } from 'ln-service'
|
import { settleHodlInvoice } from 'ln-service'
|
||||||
import { createHmac } from './wallet'
|
import { createHmac } from './wallet'
|
||||||
import { msatsToSats } from '../../lib/format'
|
import { msatsToSats, numWithUnits } from '../../lib/format'
|
||||||
|
import { BALANCE_LIMIT_MSATS } from '../../lib/constants'
|
||||||
|
|
||||||
export default async function serialize (models, ...calls) {
|
export default async function serialize (models, ...calls) {
|
||||||
return await retry(async bail => {
|
return await retry(async bail => {
|
||||||
|
@ -42,7 +43,7 @@ export default async function serialize (models, ...calls) {
|
||||||
bail(new Error('too many pending invoices'))
|
bail(new Error('too many pending invoices'))
|
||||||
}
|
}
|
||||||
if (error.message.includes('SN_INV_EXCEED_BALANCE')) {
|
if (error.message.includes('SN_INV_EXCEED_BALANCE')) {
|
||||||
bail(new Error('pending invoices must not cause balance to exceed 1m sats'))
|
bail(new Error(`pending invoices must not cause balance to exceed ${numWithUnits(msatsToSats(BALANCE_LIMIT_MSATS))}`))
|
||||||
}
|
}
|
||||||
if (error.message.includes('40001') || error.code === 'P2034') {
|
if (error.message.includes('40001') || error.code === 'P2034') {
|
||||||
throw new Error('wallet balance serialization failure - try again')
|
throw new Error('wallet balance serialization failure - try again')
|
||||||
|
|
Loading…
Reference in New Issue