ADD: lnd wallet unlock attempt upon start

This commit is contained in:
Overtorment 2019-01-25 22:59:32 +00:00
parent 0f75933bf0
commit 1df24d0e80
3 changed files with 20 additions and 0 deletions

View File

@ -11,6 +11,7 @@ let config = {
},
lnd: {
url: '1.1.1.1:10009',
password: '',
},
};

View File

@ -45,6 +45,7 @@ function updateLightning() {
} catch (Err) {
console.log(Err);
}
console.log('updated');
}
updateLightning();
setInterval(updateLightning, 60000);

View File

@ -25,4 +25,22 @@ let macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args,
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
// trying to unlock the wallet:
if (config.lnd.password) {
var walletUnlocker = new lnrpc.WalletUnlocker(config.lnd.url, creds);
walletUnlocker.unlockWallet(
{
wallet_password: config.lnd.password,
},
function(err, response) {
if (err) {
console.log('unlockWallet failed, probably because its been aleady unlocked');
} else {
console.log('unlockWallet:', response);
}
},
);
}
module.exports = new lnrpc.Lightning(config.lnd.url, creds);