Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
wip: tool for connecting to peers
Browse files Browse the repository at this point in the history
  • Loading branch information
janoside committed Jun 2, 2018
1 parent cfe2504 commit 06c0122
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
17 changes: 14 additions & 3 deletions app/rpcApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
18 changes: 18 additions & 0 deletions routes/baseActionsRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 7 additions & 0 deletions views/node.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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()})
Expand Down

0 comments on commit 06c0122

Please sign in to comment.