Compare commits

..

3 Commits

Author SHA1 Message Date
bbd41a697d Fix function context for scheduled reauth 2024-06-12 17:08:36 +02:00
04ec236c58 Update README 2024-06-12 17:08:02 +02:00
310ee0d6eb Update dependencies 2024-06-12 17:07:58 +02:00
2 changed files with 4 additions and 6 deletions

View File

@@ -121,7 +121,7 @@ function connectLndhub () {
if (connected) {
console.log("Connected to Lndhub");
// automatically refresh auth token once a day
setInterval(lndhub.reauth, 86400000);
setInterval(() => lndhub.reauth(), 86400000);
} else {
process.exit(1);
}

View File

@@ -22,7 +22,7 @@ export default class Lndhub {
async handleErroredRequest (result, retryFunction, args=[]) {
console.warn('API request failed:', result.message);
if (result.code === 1) {
return this.reauth().bind(this).then(connected => {
return this.reauth().then(connected => {
if (connected) {
console.warn('Lndhub reconnected, trying again...');
return this[retryFunction](...args);
@@ -68,8 +68,7 @@ export default class Lndhub {
let data = await this.callEndpoint('post', '/v2/invoices', payload);
if (data.error) {
return this.handleErroredRequest(data, 'createInvoice',Array.from(arguments))
.bind(this);
return this.handleErroredRequest(data, 'createInvoice', Array.from(arguments));
} else {
return data;
}
@@ -79,8 +78,7 @@ export default class Lndhub {
const data = await this.callEndpoint('get', `/v2/invoices/${paymentHash}`);
if (data.error) {
return this.handleErroredRequest(data, 'getInvoice', Array.from(arguments))
.bind(this);
return this.handleErroredRequest(data, 'getInvoice', Array.from(arguments));
} else {
return data;
}