This commit is contained in:
Overtorment 2020-05-05 08:22:29 +01:00
parent 83f6b08b82
commit 30422d9ac7
2 changed files with 42 additions and 40 deletions

View File

@ -10,7 +10,7 @@ if (process.env.TLSCERT) {
} else { } else {
lndCert = fs.readFileSync('tls.cert'); lndCert = fs.readFileSync('tls.cert');
} }
console.log('using tls.cert', lndCert.toString('hex')); process.env.VERBOSE && console.log('using tls.cert', lndCert.toString('hex'));
let sslCreds = grpc.credentials.createSsl(lndCert); let sslCreds = grpc.credentials.createSsl(lndCert);
let macaroon; let macaroon;
if (process.env.MACAROON) { if (process.env.MACAROON) {
@ -18,7 +18,7 @@ if (process.env.MACAROON) {
} else { } else {
macaroon = fs.readFileSync('admin.macaroon').toString('hex'); macaroon = fs.readFileSync('admin.macaroon').toString('hex');
} }
console.log('using macaroon', macaroon); process.env.VERBOSE && console.log('using macaroon', macaroon);
let macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) { let macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata(); let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon); metadata.add('macaroon', macaroon);
@ -28,7 +28,7 @@ let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
// trying to unlock the wallet: // trying to unlock the wallet:
if (config.lnd.password) { if (config.lnd.password) {
console.log('trying to unlock the wallet'); process.env.VERBOSE && console.log('trying to unlock the wallet');
var walletUnlocker = new lnrpc.WalletUnlocker(config.lnd.url, creds); var walletUnlocker = new lnrpc.WalletUnlocker(config.lnd.url, creds);
walletUnlocker.unlockWallet( walletUnlocker.unlockWallet(
{ {
@ -36,7 +36,7 @@ if (config.lnd.password) {
}, },
function(err, response) { function(err, response) {
if (err) { if (err) {
console.log('unlockWallet failed, probably because its been aleady unlocked'); process.env.VERBOSE && console.log('unlockWallet failed, probably because its been aleady unlocked');
} else { } else {
console.log('unlockWallet:', response); console.log('unlockWallet:', response);
} }

View File

@ -72,8 +72,8 @@ lightning.listChannels({}, function(err, response) {
} }
} }
if (process.argv.includes('--reconnect')) {
console.log('# reconnect important channels that are inactive:\n'); console.log('# reconnect important channels that are inactive:\n');
for (const important of Object.keys(important_channels)) { for (const important of Object.keys(important_channels)) {
for (let channel of lightningListChannels.channels) { for (let channel of lightningListChannels.channels) {
if (channel.remote_pubkey === important && !channel.active) { if (channel.remote_pubkey === important && !channel.active) {
@ -89,9 +89,10 @@ lightning.listChannels({}, function(err, response) {
} }
} }
} }
}
if (process.argv.includes('--open')) {
console.log('\n# open important channels:\n'); console.log('\n# open important channels:\n');
for (const important of Object.keys(important_channels)) { for (const important of Object.keys(important_channels)) {
let atLeastOneChannelIsSufficientCapacity = false; let atLeastOneChannelIsSufficientCapacity = false;
for (let channel of lightningListChannels.channels) { for (let channel of lightningListChannels.channels) {
@ -116,6 +117,7 @@ lightning.listChannels({}, function(err, response) {
); );
} }
} }
}
process.exit(); process.exit();
}); });