Wait longer, increase check interval for payment checks

This commit is contained in:
Râu Cao 2023-11-22 21:07:01 +01:00
parent d34c8ff0cd
commit b51bbd446c
Signed by: raucao
GPG Key ID: 15E65F399D084BA9

View File

@ -42,16 +42,24 @@ function startPingInterval () {
} }
function waitForInvoicePaid (room, nick, invoice, retries=0) { function waitForInvoicePaid (room, nick, invoice, retries=0) {
let timeout = 3000;
if (retries >= 300) { if (retries >= 300) {
console.log(`Invoice not paid after 15 minutes: ${invoice.payment_hash}`); console.log(`Invoice not paid after 15 minutes: ${invoice.payment_hash}`);
return false; let timeout = 5000;
if (retries >= 500) {
// TODO ask user to request voice again to create a new invoice
return false;
}
} }
lndhub.getInvoice(invoice.payment_hash).then(async data => { lndhub.getInvoice(invoice.payment_hash).then(async data => {
if (data.is_paid) { if (data.is_paid) {
console.log(`Invoice paid: ${invoice.payment_hash}`); console.log(`Invoice paid: ${invoice.payment_hash}`);
await grantVoice(room, nick); await grantVoice(room, nick);
} else { } else {
setTimeout(waitForInvoicePaid, 3000, room, nick, invoice, retries++); setTimeout(waitForInvoicePaid, 3000, room, nick, invoice, retries++);
setTimeout(waitForInvoicePaid, timeout, room, nick, invoice, retries++);
} }
}); });
} }