REF
This commit is contained in:
parent
83f6b08b82
commit
30422d9ac7
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -72,50 +72,52 @@ lightning.listChannels({}, function(err, response) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('# reconnect important channels that are inactive:\n');
|
if (process.argv.includes('--reconnect')) {
|
||||||
|
console.log('# reconnect important channels that are inactive:\n');
|
||||||
|
for (const important of Object.keys(important_channels)) {
|
||||||
|
for (let channel of lightningListChannels.channels) {
|
||||||
|
if (channel.remote_pubkey === important && !channel.active) {
|
||||||
|
console.log(
|
||||||
|
'lncli disconnect',
|
||||||
|
channel.remote_pubkey,
|
||||||
|
'; sleep 5;',
|
||||||
|
'lncli connect',
|
||||||
|
important_channels[channel.remote_pubkey].uri,
|
||||||
|
'#',
|
||||||
|
important_channels[channel.remote_pubkey].name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const important of Object.keys(important_channels)) {
|
if (process.argv.includes('--open')) {
|
||||||
for (let channel of lightningListChannels.channels) {
|
console.log('\n# open important channels:\n');
|
||||||
if (channel.remote_pubkey === important && !channel.active) {
|
for (const important of Object.keys(important_channels)) {
|
||||||
|
let atLeastOneChannelIsSufficientCapacity = false;
|
||||||
|
for (let channel of lightningListChannels.channels) {
|
||||||
|
if (channel.remote_pubkey === important && channel.local_balance >= 4000000 && channel.active) {
|
||||||
|
atLeastOneChannelIsSufficientCapacity = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!atLeastOneChannelIsSufficientCapacity) {
|
||||||
console.log(
|
console.log(
|
||||||
'lncli disconnect',
|
'lncli disconnect',
|
||||||
channel.remote_pubkey,
|
important,
|
||||||
'; sleep 5;',
|
'; sleep 3;',
|
||||||
'lncli connect',
|
'lncli openchannel --node_key',
|
||||||
important_channels[channel.remote_pubkey].uri,
|
important,
|
||||||
|
'--connect',
|
||||||
|
important_channels[important].uri.split('@')[1],
|
||||||
|
'--local_amt',
|
||||||
|
important_channels[important].wumbo ? '167772150' : '16777215',
|
||||||
'#',
|
'#',
|
||||||
important_channels[channel.remote_pubkey].name,
|
important_channels[important].name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('\n# open important channels:\n');
|
|
||||||
|
|
||||||
for (const important of Object.keys(important_channels)) {
|
|
||||||
let atLeastOneChannelIsSufficientCapacity = false;
|
|
||||||
for (let channel of lightningListChannels.channels) {
|
|
||||||
if (channel.remote_pubkey === important && channel.local_balance >= 4000000 && channel.active) {
|
|
||||||
atLeastOneChannelIsSufficientCapacity = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!atLeastOneChannelIsSufficientCapacity) {
|
|
||||||
console.log(
|
|
||||||
'lncli disconnect',
|
|
||||||
important,
|
|
||||||
'; sleep 3;',
|
|
||||||
'lncli openchannel --node_key',
|
|
||||||
important,
|
|
||||||
'--connect',
|
|
||||||
important_channels[important].uri.split('@')[1],
|
|
||||||
'--local_amt',
|
|
||||||
important_channels[important].wumbo ? '167772150' : '16777215',
|
|
||||||
'#',
|
|
||||||
important_channels[important].name,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user