REF
This commit is contained in:
parent
260c5760aa
commit
7674efb2a2
7
bitcoin.js
Normal file
7
bitcoin.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// setup bitcoind rpc
|
||||||
|
const config = require('./config');
|
||||||
|
let jayson = require('jayson/promise');
|
||||||
|
let url = require('url');
|
||||||
|
let rpc = url.parse(config.bitcoind.rpc);
|
||||||
|
rpc.timeout = 5000;
|
||||||
|
module.exports = jayson.client.http(rpc);
|
@ -5,7 +5,6 @@ let router = express.Router();
|
|||||||
let assert = require('assert');
|
let assert = require('assert');
|
||||||
console.log('using config', JSON.stringify(config));
|
console.log('using config', JSON.stringify(config));
|
||||||
|
|
||||||
// setup redis
|
|
||||||
var Redis = require('ioredis');
|
var Redis = require('ioredis');
|
||||||
var redis = new Redis(config.redis);
|
var redis = new Redis(config.redis);
|
||||||
redis.monitor(function(err, monitor) {
|
redis.monitor(function(err, monitor) {
|
||||||
@ -14,40 +13,8 @@ redis.monitor(function(err, monitor) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// setup bitcoind rpc
|
let bitcoinclient = require('../bitcoin');
|
||||||
let jayson = require('jayson/promise');
|
let lightning = require('../lightning');
|
||||||
let url = require('url');
|
|
||||||
let rpc = url.parse(config.bitcoind.rpc);
|
|
||||||
rpc.timeout = 5000;
|
|
||||||
let bitcoinclient = jayson.client.http(rpc);
|
|
||||||
|
|
||||||
// setup lnd rpc
|
|
||||||
var fs = require('fs');
|
|
||||||
var grpc = require('grpc');
|
|
||||||
var lnrpc = grpc.load('rpc.proto').lnrpc;
|
|
||||||
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
|
|
||||||
var lndCert;
|
|
||||||
if (process.env.TLSCERT) {
|
|
||||||
lndCert = Buffer.from(process.env.TLSCERT, 'hex');
|
|
||||||
} 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) {
|
|
||||||
macaroon = process.env.MACAROON;
|
|
||||||
} else {
|
|
||||||
macaroon = fs.readFileSync('admin.macaroon').toString('hex');
|
|
||||||
}
|
|
||||||
console.log('using macaroon', macaroon);
|
|
||||||
let macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
|
|
||||||
let metadata = new grpc.Metadata();
|
|
||||||
metadata.add('macaroon', macaroon);
|
|
||||||
callback(null, metadata);
|
|
||||||
});
|
|
||||||
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
|
|
||||||
let lightning = new lnrpc.Lightning(config.lnd.url, creds);
|
|
||||||
|
|
||||||
// ###################### SMOKE TESTS ########################
|
// ###################### SMOKE TESTS ########################
|
||||||
|
|
||||||
|
28
lightning.js
Normal file
28
lightning.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// setup lnd rpc
|
||||||
|
const config = require('./config');
|
||||||
|
var fs = require('fs');
|
||||||
|
var grpc = require('grpc');
|
||||||
|
var lnrpc = grpc.load('rpc.proto').lnrpc;
|
||||||
|
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
|
||||||
|
var lndCert;
|
||||||
|
if (process.env.TLSCERT) {
|
||||||
|
lndCert = Buffer.from(process.env.TLSCERT, 'hex');
|
||||||
|
} 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) {
|
||||||
|
macaroon = process.env.MACAROON;
|
||||||
|
} else {
|
||||||
|
macaroon = fs.readFileSync('admin.macaroon').toString('hex');
|
||||||
|
}
|
||||||
|
console.log('using macaroon', macaroon);
|
||||||
|
let macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
|
||||||
|
let metadata = new grpc.Metadata();
|
||||||
|
metadata.add('macaroon', macaroon);
|
||||||
|
callback(null, metadata);
|
||||||
|
});
|
||||||
|
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
|
||||||
|
module.exports = new lnrpc.Lightning(config.lnd.url, creds);
|
Loading…
x
Reference in New Issue
Block a user