Browse Source

mac path from config

push-params
Evan Feenstra 4 years ago
parent
commit
e44bcefdd9
  1. 11
      api/builtin/loop.ts
  2. 10
      dist/api/builtin/loop.js
  3. 2
      dist/api/builtin/loop.js.map

11
api/builtin/loop.ts

@ -1,9 +1,12 @@
import * as Sphinx from 'sphinx-bot'
import { finalAction } from '../controllers/actions'
import fetch from 'node-fetch'
import * as path from 'path'
var validate = require('bitcoin-address-validation');
const msg_types = Sphinx.MSG_TYPE
// /home/ec2-user/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
let initted = false
const baseurl = 'https://localhost:8080'
@ -62,6 +65,7 @@ export function init() {
.setTitle('Loop Initialized!')
.setDescription(j2.server_message)
message.channel.send({ embed })
return
} catch (e) {
console.log('LoopBot error', e)
}
@ -102,17 +106,18 @@ function validateAmount(amtString: string) {
const fs = require('fs')
const https = require("https");
const homedir = require('os').homedir();
// const homedir = require('os').homedir();
const agent = new https.Agent({
rejectUnauthorized: false
})
var filepath = homedir + '/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname,'../../config/app.json'))[env]
async function doRequest(theurl:string, params?:Object) {
const ps = params || {}
try {
var macaroonString = fs.readFileSync(filepath);
var macaroonString = fs.readFileSync(config.macaroon_location);
var mac = Buffer.from(macaroonString, 'utf8').toString('hex');
const theParams = {
agent,

10
dist/api/builtin/loop.js

@ -12,8 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
const Sphinx = require("sphinx-bot");
const actions_1 = require("../controllers/actions");
const node_fetch_1 = require("node-fetch");
const path = require("path");
var validate = require('bitcoin-address-validation');
const msg_types = Sphinx.MSG_TYPE;
// /home/ec2-user/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
let initted = false;
const baseurl = 'https://localhost:8080';
function init() {
@ -70,6 +72,7 @@ function init() {
.setTitle('Loop Initialized!')
.setDescription(j2.server_message);
message.channel.send({ embed });
return;
}
catch (e) {
console.log('LoopBot error', e);
@ -108,16 +111,17 @@ function validateAmount(amtString) {
}
const fs = require('fs');
const https = require("https");
const homedir = require('os').homedir();
// const homedir = require('os').homedir();
const agent = new https.Agent({
rejectUnauthorized: false
});
var filepath = homedir + '/.lnd/data/chain/bitcoin/mainnet/admin.macaroon';
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname, '../../config/app.json'))[env];
function doRequest(theurl, params) {
return __awaiter(this, void 0, void 0, function* () {
const ps = params || {};
try {
var macaroonString = fs.readFileSync(filepath);
var macaroonString = fs.readFileSync(config.macaroon_location);
var mac = Buffer.from(macaroonString, 'utf8').toString('hex');
const theParams = Object.assign({ agent, headers: {
'Grpc-Metadata-macaroon': mac

2
dist/api/builtin/loop.js.map

@ -1 +1 @@
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../../api/builtin/loop.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qCAAoC;AACpC,oDAAoD;AACpD,2CAA8B;AAC9B,IAAI,QAAQ,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AACrD,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAA;AAEjC,IAAI,OAAO,GAAG,KAAK,CAAA;AAEnB,MAAM,OAAO,GAAG,wBAAwB,CAAA;AAExC,SAAgB,IAAI;IAClB,IAAI,OAAO;QAAE,OAAM;IACnB,OAAO,GAAG,IAAI,CAAA;IAEd,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,CAAA;IAClC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,qBAAW,CAAC,CAAA;IAE9B,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,CAAO,OAAuB,EAAE,EAAE;QAC7D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACtC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;YAAE,OAAM;QAC1B,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,UAAU;YAA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