Automatically refresh lndhub token once a day
This commit is contained in:
parent
35844b577c
commit
833ab50616
2
index.js
2
index.js
@ -120,6 +120,8 @@ function connectLndhub () {
|
|||||||
return lndhub.auth(config.lndhub.username, config.lndhub.password).then(connected => {
|
return lndhub.auth(config.lndhub.username, config.lndhub.password).then(connected => {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
console.log("Connected to Lndhub");
|
console.log("Connected to Lndhub");
|
||||||
|
// automatically refresh auth token once a day
|
||||||
|
setInterval(lndhub.reauth, 86400000);
|
||||||
} else {
|
} else {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,9 @@ export default class Lndhub {
|
|||||||
console.warn('Lndhub re-auth failed:', data.message);
|
console.warn('Lndhub re-auth failed:', data.message);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
if (this.accessToken !== data.access_token) {
|
||||||
|
console.log('Lndhub access token refreshed');
|
||||||
|
}
|
||||||
this.accessToken = data.access_token;
|
this.accessToken = data.access_token;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user