Wait longer, increase check interval for payment checks
This commit is contained in:
parent
d34c8ff0cd
commit
b51bbd446c
10
index.js
10
index.js
@ -42,16 +42,24 @@ function startPingInterval () {
|
||||
}
|
||||
|
||||
function waitForInvoicePaid (room, nick, invoice, retries=0) {
|
||||
let timeout = 3000;
|
||||
|
||||
if (retries >= 300) {
|
||||
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 => {
|
||||
if (data.is_paid) {
|
||||
console.log(`Invoice paid: ${invoice.payment_hash}`);
|
||||
await grantVoice(room, nick);
|
||||
} else {
|
||||
setTimeout(waitForInvoicePaid, 3000, room, nick, invoice, retries++);
|
||||
setTimeout(waitForInvoicePaid, timeout, room, nick, invoice, retries++);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user