Automatically refresh lndhub token once a day

This commit is contained in:
Râu Cao 2023-11-22 21:12:24 +01:00
parent 35844b577c
commit 833ab50616
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
2 changed files with 5 additions and 0 deletions

View File

@ -120,6 +120,8 @@ function connectLndhub () {
return lndhub.auth(config.lndhub.username, config.lndhub.password).then(connected => {
if (connected) {
console.log("Connected to Lndhub");
// automatically refresh auth token once a day
setInterval(lndhub.reauth, 86400000);
} else {
process.exit(1);
}

View File

@ -56,6 +56,9 @@ export default class Lndhub {
console.warn('Lndhub re-auth failed:', data.message);
return false;
} else {
if (this.accessToken !== data.access_token) {
console.log('Lndhub access token refreshed');
}
this.accessToken = data.access_token;
return true;
}