Merge branch 'bluewallet-lndhub'

This commit is contained in:
Agustin Kassis 2020-03-20 20:32:07 -03:00
commit 376a3402bd
9 changed files with 436 additions and 448 deletions

View File

@ -3,5 +3,5 @@ const config = require('./config');
let jayson = require('jayson/promise');
let url = require('url');
let rpc = url.parse(config.bitcoind.rpc);
rpc.timeout = 5000;
rpc.timeout = 15000;
module.exports = jayson.client.http(rpc);

View File

@ -1,17 +1,17 @@
let config = {
bitcoind: {
rpc: 'http://login:password@1.1.1.1:8332',
rpc: 'http://masize:12345678@127.0.0.1:18443',
},
redis: {
port: 12914,
host: '1.1.1.1',
port: 6379,
host: '127.0.0.1',
family: 4,
password: 'password',
//password: 'password',
db: 0,
},
lnd: {
url: '1.1.1.1:10009',
password: '',
url: '127.0.0.1:10009',
password: 'masize1535',
},
};

View File

@ -25,17 +25,19 @@ bitcoinclient.request('getblockchaininfo', false, function(err, info) {
process.exit(1);
}
} else {
console.error('bitcoind failure');
console.error('bitcoind failure:', err, info);
process.exit(2);
}
});
lightning.getInfo({}, function(err, info) {
if (err) {
console.error('lnd failure');
console.error('lnd failure shuuu');
console.dir(err);
process.exit(3);
}
if (info) {
console.info(info);
if (!info.synced_to_chain) {
console.error('lnd not synced');
process.exit(4);
@ -56,7 +58,7 @@ redis.info(function(err, info) {
const rateLimit = require('express-rate-limit');
const postLimiter = rateLimit({
windowMs: 30 * 60 * 1000,
max: 50,
max: 100,
});
router.post('/create', postLimiter, async function(req, res) {
@ -348,6 +350,22 @@ router.get('/getuserinvoices', async function(req, res) {
}
});
router.get('/checkinvoicepaid', async function(req, res) {
logger.log('/checkinvoicepaid', [req.id]);
let u = new User(redis, bitcoinclient, lightning);
if (!(await u.loadByAuthorization(req.headers.authorization))) {
return errorBadAuth(res);
}
try {
let paid = await u.getPaymentHashPaid(req.query.pay_req);
res.send(paid);
} catch (Err) {
logger.log('', [req.id, 'error getting invoice:', Err.message, 'userid:', u.getUserId()]);
res.send(false);
}
});
router.get('/getpending', async function(req, res) {
logger.log('/getpending', [req.id]);
let u = new User(redis, bitcoinclient, lightning);

View File

@ -19,13 +19,13 @@ function updateLightning() {
lightning.listChannels({}, function(err, response) {
if (err) {
console.error('lnd failure:', err);
console.error('lnd 2 failure:', err);
return;
}
lightningListChannels = response;
let channels = [];
for (let channel of lightningListChannels.channels) {
let divider = 524287;
let divider = 5242870;
let ascii_length1 = channel.local_balance / divider;
let ascii_length2 = channel.remote_balance / divider;
channel.ascii = '[';
@ -75,7 +75,7 @@ const pubkey2name = {
router.get('/', function(req, res) {
logger.log('/', [req.id]);
if (!lightningGetInfo) {
console.error('lnd failure');
console.error('lnd failurefff');
process.exit(3);
}
res.setHeader('Content-Type', 'text/html');

View File

@ -19,7 +19,7 @@ app.enable('trust proxy');
const rateLimit = require('express-rate-limit');
const limiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 100,
max: 200,
});
app.use(limiter);

View File

@ -10,7 +10,6 @@ if (process.env.TLSCERT) {
} else {
lndCert = fs.readFileSync('tls.cert');
}
console.log('using tls.cert', lndCert.toString('hex'));
let sslCreds = grpc.credentials.createSsl(lndCert);
let macaroon;
if (process.env.MACAROON) {

809
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,12 +14,12 @@
"dependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.1",
"babel-eslint": "^10.1.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-register": "^6.26.0",
"bignumber.js": "^8.0.1",
"bignumber.js": "^9.0.0",
"bolt11": "^1.2.6",
"eslint": "^5.9.0",
"eslint-config-prettier": "^3.3.0",

View File

@ -1,15 +1,22 @@
let important_channels = {
'02d23fa6794d8fd056c757f3c8f4877782138dafffedc831fc570cab572620dc61': 'paywithmoon.com',
const important_channels = {
'03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f': 'ACINQ',
'03abf6f44c355dec0d5aa155bdbdd6e0c8fefe318eff402de65c6eb2e1be55dc3e': 'OpenNode',
'0242a4ae0c5bef18048fbecf995094b74bfb0f7391418d71ed394784373f41e4f3': 'coingate.com',
'0254ff808f53b2f8c45e74b70430f336c6c76ba2f4af289f48d6086ae6e60462d3': 'bitrefill thor',
'030c3f19d742ca294a55c00376b3b355c3c90d61c6b6b39554dbc7ac19b141c14f': 'bitrefill 2',
'025f1456582e70c4c06b61d5c8ed3ce229e6d0db538be337a2dc6d163b0ebc05a5': 'paywithmoon.com',
'02c91d6aa51aa940608b497b6beebcb1aec05be3c47704b682b3889424679ca490': 'lnbig 21',
'0279c22ed7a068d10dc1a38ae66d2d6461e269226c60258c021b1ddcdfe4b00bc4': 'ln1.satoshilabs.com',
'026c7d28784791a4b31a64eb34d9ab01552055b795919165e6ae886de637632efb': 'LivingRoomOfSatoshi',
'02816caed43171d3c9854e3b0ab2cf0c42be086ff1bd4005acc2a5f7db70d83774': 'ln.pizza',
'02816caed43171d3c9854e3b0ab2cf0c42be086ff1bd4005acc2a5f7db70d83774': 'ln.pizza aka fold',
};
const wumbo = {
'03abf6f44c355dec0d5aa155bdbdd6e0c8fefe318eff402de65c6eb2e1be55dc3e': true, // opennode
'0254ff808f53b2f8c45e74b70430f336c6c76ba2f4af289f48d6086ae6e60462d3': true, // bitrefill
'030c3f19d742ca294a55c00376b3b355c3c90d61c6b6b39554dbc7ac19b141c14f': true, // bitrefill 2
'02816caed43171d3c9854e3b0ab2cf0c42be086ff1bd4005acc2a5f7db70d83774': true, // fold
};
let lightning = require('../lightning');
lightning.listChannels({}, function(err, response) {
@ -42,7 +49,14 @@ lightning.listChannels({}, function(err, response) {
}
if (!atLeastOneChannelIsSufficientCapacity) {
console.log('lncli openchannel --node_key ', important, '--local_amt 16777215', '#', important_channels[important]);
console.log(
'lncli openchannel --node_key',
important,
'--local_amt',
wumbo[important] ? '167772150' : '16777215',
'#',
important_channels[important],
);
}
}