Browse Source

configurable creds

jsc2
Evan Feenstra 4 years ago
parent
commit
87f0673dff
  1. 4
      dist/src/utils/lightning.js
  2. 2
      dist/src/utils/lightning.js.map
  3. 8
      dist/src/utils/macaroon.js
  4. 2
      dist/src/utils/macaroon.js.map
  5. 2
      dist/src/utils/signer.js
  6. 2
      dist/src/utils/signer.js.map
  7. 4
      src/utils/lightning.ts
  8. 8
      src/utils/macaroon.ts
  9. 2
      src/utils/signer.ts

4
dist/src/utils/lightning.js

@ -27,10 +27,10 @@ const SPHINX_CUSTOM_RECORD_KEY = 133773310;
exports.SPHINX_CUSTOM_RECORD_KEY = SPHINX_CUSTOM_RECORD_KEY;
var lightningClient = null;
var walletUnlocker = null;
const loadCredentials = () => {
const loadCredentials = (macName) => {
var lndCert = fs.readFileSync(config.tls_location);
var sslCreds = grpc.credentials.createSsl(lndCert);
var macaroon = macaroon_1.getMacaroon();
var macaroon = macaroon_1.getMacaroon(macName);
var metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
var macaroonCreds = grpc.credentials.createFromMetadataGenerator((_args, callback) => {

2
dist/src/utils/lightning.js.map

File diff suppressed because one or more lines are too long

8
dist/src/utils/macaroon.js

@ -4,12 +4,16 @@ const fs = require("fs");
const config_1 = require("./config");
const config = config_1.loadConfig();
let inMemoryMacaroon = ''; // hex encoded
function getMacaroon() {
function getMacaroon(macName) {
if (config.unlock) {
return inMemoryMacaroon;
}
else {
const m = fs.readFileSync(config.macaroon_location);
let macLocation = config.macaroon_location;
if (macName) {
macLocation = macLocation.replace(/admin.macaroon/, macName);
}
const m = fs.readFileSync(macLocation);
return m.toString('hex');
}
}

2
dist/src/utils/macaroon.js.map

@ -1 +1 @@
{"version":3,"file":"macaroon.js","sourceRoot":"","sources":["../../../src/utils/macaroon.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AACxB,qCAAmC;AAEnC,MAAM,MAAM,GAAG,mBAAU,EAAE,CAAA;AAE3B,IAAI,gBAAgB,GAAW,EAAE,CAAC,CAAC,cAAc;AAEjD,SAAgB,WAAW;IACzB,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,OAAO,gBAAgB,CAAA;KACxB;SAAM;QACL,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;QACnD,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KAC1B;AACH,CAAC;AAPD,kCAOC;AAED,SAAgB,mBAAmB,CAAC,GAAW;IAC7C,gBAAgB,GAAG,GAAG,CAAA;AACxB,CAAC;AAFD,kDAEC"}
{"version":3,"file":"macaroon.js","sourceRoot":"","sources":["../../../src/utils/macaroon.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AACxB,qCAAmC;AAEnC,MAAM,MAAM,GAAG,mBAAU,EAAE,CAAA;AAE3B,IAAI,gBAAgB,GAAW,EAAE,CAAC,CAAC,cAAc;AAEjD,SAAgB,WAAW,CAAC,OAAe;IACzC,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,OAAO,gBAAgB,CAAA;KACxB;SAAM;QACL,IAAI,WAAW,GAAG,MAAM,CAAC,iBAAiB,CAAA;QAC1C,IAAG,OAAO,EAAE;YACV,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;SAC7D;QACD,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;QACtC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KAC1B;AACH,CAAC;AAXD,kCAWC;AAED,SAAgB,mBAAmB,CAAC,GAAW;IAC7C,gBAAgB,GAAG,GAAG,CAAA;AACxB,CAAC;AAFD,kDAEC"}

2
dist/src/utils/signer.js

@ -23,7 +23,7 @@ exports.loadSigner = () => {
}
else {
try {
var credentials = lightning_1.loadCredentials();
var credentials = lightning_1.loadCredentials('signer.macaroon');
var lnrpcDescriptor = grpc.load("proto/signer.proto");
var signer = lnrpcDescriptor.signrpc;
signerClient = new signer.Signer(LND_IP + ':' + config.lnd_port, credentials);

2
dist/src/utils/signer.js.map

@ -1 +1 @@
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../src/utils/signer.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,6BAA4B;AAC5B,2CAA6C;AAC7C,yCAAwC;AACxC,qCAAmC;AAEnC,kDAAkD;AAClD,MAAM,MAAM,GAAG,mBAAU,EAAE,CAAA;AAC3B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,WAAW,CAAA;AAE3C,IAAI,YAAY,GAAQ,IAAI,CAAC;AAEhB,QAAA,UAAU,GAAG,GAAG,EAAE;IAC7B,IAAI,YAAY,EAAE;QAChB,OAAO,YAAY,CAAA;KACpB;SAAM;QACL,IAAI;YACF,IAAI,WAAW,GAAG,2BAAe,EAAE,CAAA;YACnC,IAAI,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACtD,IAAI,MAAM,GAAQ,eAAe,CAAC,OAAO,CAAA;YACzC,YAAY,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;YAC9E,OAAO,YAAY,CAAA;SACpB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAA;SACR;KACF;AACH,CAAC,CAAA;AAEY,QAAA,WAAW,GAAG,CAAC,GAAG,EAAE,EAAE;IACjC,OAAO,IAAI,OAAO,CAAC,CAAO,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,MAAM,GAAG,MAAM,kBAAU,EAAE,CAAA;QAC/B,IAAI;YACF,MAAM,OAAO,GAAG;gBACd,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC;gBAC5B,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;aACzC,CAAA;YACD,MAAM,CAAC,W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CAAC,CAAA;iBACb;YACH,CAAC,CAAC,CAAA;SACH;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAC,CAAC,CAAA;SACV;IACH,CAAC,CAAA,CAAC,CAAA;AACJ,CAAC;AAED,SAAsB,SAAS,CAAC,KAAK;;QACnC,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,mBAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;YACnD,OAAO,GAAG,CAAA;SACX;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAA;SACR;IACH,CAAC;CAAA;AAPD,8BAOC;AAED,SAAsB,WAAW,CAAC,KAAa,EAAE,GAAW,EAAE,MAAc;;QAC1E,IAAI;YACF,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;YAChE,OAAO,CAAC,CAAA;SACT;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAA;SACR;IACH,CAAC;CAAA;AAPD,kCAOC;AAED,SAAS,aAAa,CAAC,GAAG;IACxB,IAAI,IAAI,GAAa,EAAE,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1C,IAAI,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAChB;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvB,CAAC"}

4
src/utils/lightning.ts

@ -18,10 +18,10 @@ const SPHINX_CUSTOM_RECORD_KEY = 133773310
var lightningClient = <any>null;
var walletUnlocker = <any>null;
const loadCredentials = () => {
const loadCredentials = (macName?:string) => {
var lndCert = fs.readFileSync(config.tls_location);
var sslCreds = grpc.credentials.createSsl(lndCert);
var macaroon = getMacaroon()
var macaroon = getMacaroon(macName)
var metadata = new grpc.Metadata()
metadata.add('macaroon', macaroon)
var macaroonCreds = grpc.credentials.createFromMetadataGenerator((_args, callback) => {

8
src/utils/macaroon.ts

@ -5,11 +5,15 @@ const config = loadConfig()
let inMemoryMacaroon: string = ''; // hex encoded
export function getMacaroon() {
export function getMacaroon(macName?:string) {
if (config.unlock) {
return inMemoryMacaroon
} else {
const m = fs.readFileSync(config.macaroon_location)
let macLocation = config.macaroon_location
if(macName) {
macLocation = macLocation.replace(/admin.macaroon/, macName)
}
const m = fs.readFileSync(macLocation)
return m.toString('hex');
}
}

2
src/utils/signer.ts

@ -15,7 +15,7 @@ export const loadSigner = () => {
return signerClient
} else {
try {
var credentials = loadCredentials()
var credentials = loadCredentials('signer.macaroon')
var lnrpcDescriptor = grpc.load("proto/signer.proto");
var signer: any = lnrpcDescriptor.signrpc
signerClient = new signer.Signer(LND_IP + ':' + config.lnd_port, credentials);

Loading…
Cancel
Save