select first status=null on withdrawal check
This commit is contained in:
parent
2ff839f3a5
commit
a495c421ce
@ -239,9 +239,14 @@ async function subscribeToWithdrawals (args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function checkWithdrawal ({ data: { hash }, boss, models, lnd }) {
|
export async function checkWithdrawal ({ data: { hash }, boss, models, lnd }) {
|
||||||
|
// get the withdrawl if pending or it's an invoiceForward
|
||||||
const dbWdrwl = await models.withdrawl.findFirst({
|
const dbWdrwl = await models.withdrawl.findFirst({
|
||||||
where: {
|
where: {
|
||||||
hash
|
hash,
|
||||||
|
OR: [
|
||||||
|
{ status: null },
|
||||||
|
{ invoiceForward: { some: { } } }
|
||||||
|
]
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
wallet: true,
|
wallet: true,
|
||||||
@ -253,16 +258,9 @@ export async function checkWithdrawal ({ data: { hash }, boss, models, lnd }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (!dbWdrwl) {
|
|
||||||
// [WARNING] LND paid an invoice that wasn't created via the SN GraphQL API.
|
|
||||||
// >>> an adversary might be draining our funds right now <<<
|
|
||||||
console.error('unexpected outgoing payment detected:', hash)
|
|
||||||
// TODO: log this in Slack
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// already recorded and no invoiceForward to handle
|
// nothing to do if the withdrawl is already recorded and it isn't an invoiceForward
|
||||||
if (dbWdrwl.status && dbWdrwl.invoiceForward.length === 0) return
|
if (!dbWdrwl) return
|
||||||
|
|
||||||
let wdrwl
|
let wdrwl
|
||||||
let notSent = false
|
let notSent = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user