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 => {
|
||||
if (connected) {
|
||||
console.log("Connected to Lndhub");
|
||||
// automatically refresh auth token once a day
|
||||
setInterval(lndhub.reauth, 86400000);
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user