Permalink
Browse files

wip: tool for connecting to peers

  • Loading branch information...
janoside committed Jun 2, 2018
1 parent cfe2504 commit 06c012211664c75b8a8d0a67778ab3d8bc4c9ce3
Showing with 39 additions and 3 deletions.
  1. +14 −3 app/rpcApi.js
  2. +18 −0 routes/baseActionsRouter.js
  3. +7 −0 views/node.pug
@@ -125,12 +125,23 @@ function compileFullNetworkDescription(describeGraphResponse, nodeInfoByPubkey)
}
});
return fnd;
}
function connectToPeer(pubKey, address) {
return new Promise(function(resolve, reject) {
lightning.connect(pubKey + "@" + address).then(function(err, response) {
if (err) {
console.log("Error 23urh0efygf: " + err);
}
resolve(response);
});
});
}
module.exports = {
getFullNetworkDescription: getFullNetworkDescription,
refreshFullNetworkDescription: refreshFullNetworkDescription
refreshFullNetworkDescription: refreshFullNetworkDescription,
connectToPeer: connectToPeer
};
@@ -222,4 +222,22 @@ router.get("/about", function(req, res) {
res.render("about");
});
router.get("/connectToPeer", function(req, res) {
if (!req.query.pubKey) {
req.session.userMessage = "Unable to connect to peer: missing pubKey";
res.redirect(req.headers.referer);
}
if (!req.query.address) {
req.session.userMessage = "Unable to connect to peer: missing address";
res.redirect(req.headers.referer);
}
rpcApi.connectToPeer(req.query.pubKey, req.query.address).then(function(response) {
res.redirect(req.headers.referer);
});
});
module.exports = router;
@@ -52,6 +52,13 @@ block content
th(class="table-active properties-header") Total Capacity
td(class="monospace") #{parseInt(nodeInfo.total_capacity).toLocaleString()}
div(class="card")
div(class="card-header")
span(class="h6") Actions
div(class="card-body")
if (nodeInfo.node.addresses && nodeInfo.node.addresses.length > 0)
a(href=("/connectToPeer?pubKey=" + nodeInfo.node.pub_key + "&address=" + nodeInfo.node.addresses[0].addr), class="btn btn-primary") Connect as Peer
div(class="card")
div(class="card-header")
span(class="h6") Channels (#{parseInt(nodeInfo.num_channels).toLocaleString()})

0 comments on commit 06c0122

Please sign in to comment.