Browse Source

get node pubkey from hub api

master^2
Evan Feenstra 4 years ago
parent
commit
6ccbb81ba1
  1. 17
      dist/src/controllers/queries.js
  2. 2
      dist/src/controllers/queries.js.map
  3. 16
      src/controllers/queries.ts

17
dist/src/controllers/queries.js

@ -21,8 +21,19 @@ const sequelize_1 = require("sequelize");
const node_fetch_1 = require("node-fetch");
const helpers = require("../helpers");
let queries = {};
// const hub_pubkey = '023d70f2f76d283c6c4e58109ee3a2816eb9d8feb40b23d62469060a2b2867b77f'
const hub_pubkey = '02290714deafd0cb33d2be3b634fc977a98a9c9fa1dd6c53cf17d99b350c08c67b';
let hub_pubkey = '';
const hub_url = 'https://hub.sphinx.chat/api/v1/';
function get_hub_pubkey() {
return __awaiter(this, void 0, void 0, function* () {
const r = yield node_fetch_1.default(hub_url + '/routingnode');
const j = yield r.json();
if (j && j.pubkey) {
console.log("=> GOT HUB PUBKEY", j.pubkey);
hub_pubkey = j.pubkey;
}
});
}
get_hub_pubkey();
function getReceivedAccountings() {
return __awaiter(this, void 0, void 0, function* () {
const accountings = yield models_1.models.Accounting.findAll({
@ -198,6 +209,8 @@ exports.startWatchingUTXOs = startWatchingUTXOs;
function queryOnchainAddress(req, res) {
return __awaiter(this, void 0, void 0, function* () {
console.log('=> queryOnchainAddress');
if (!hub_pubkey)
return console.log("=> NO ROUTING NODE PUBKEY SET");
const uuid = short.generate();
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const app = req.params.app;

2
dist/src/controllers/queries.js.map

File diff suppressed because one or more lines are too long

16
src/controllers/queries.ts

@ -20,8 +20,18 @@ export interface Query {
let queries: { [k: string]: Query } = {}
// const hub_pubkey = '023d70f2f76d283c6c4e58109ee3a2816eb9d8feb40b23d62469060a2b2867b77f'
const hub_pubkey = '02290714deafd0cb33d2be3b634fc977a98a9c9fa1dd6c53cf17d99b350c08c67b'
let hub_pubkey = ''
const hub_url = 'https://hub.sphinx.chat/api/v1/'
async function get_hub_pubkey(){
const r = await fetch(hub_url+'/routingnode')
const j = await r.json()
if(j && j.pubkey) {
console.log("=> GOT HUB PUBKEY", j.pubkey)
hub_pubkey = j.pubkey
}
}
get_hub_pubkey()
interface Accounting {
id: number
@ -190,6 +200,8 @@ export function startWatchingUTXOs() {
export async function queryOnchainAddress(req, res) {
console.log('=> queryOnchainAddress')
if(!hub_pubkey) return console.log("=> NO ROUTING NODE PUBKEY SET")
const uuid = short.generate()
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const app = req.params.app;

Loading…
Cancel
Save