SatoshiPortal / cyphernode

Modular Bitcoin full-node microservices API server architecture and utilities toolkit to build scalable, secure and featureful apps and services without trusted third parties
MIT License
364 stars 68 forks source link

Clarification of the Proxy and how it works #138

Closed chrisjmccreadie closed 4 years ago

chrisjmccreadie commented 4 years ago

This is not so much but a way of clarification as I am sure it is working as intended but I am just not smart enough to have figured what that intended way it.

The issue I have is whenever I try to interface with the proxy via a CURL command I cannot get a response. For instance, if I do a GET call to this via postman, curl or calling directly from a browser I do not get any response.

http://cyphernode:8888/getactivewatches (I have replaced cyphernode with 127.0.0.1 etc nothing works)

I get a page not found. However, if I were to access the proxy as it is shown elsewhere in the docs. I can call the get block chain info command in the following manner (which works ) for example.

echo "GET /getblockchaininfo" | docker run --rm -i --network=cyphernodenet alpine nc proxy:8888 -

I can also get the blockchain info by doing a curl command directly because bitcoin-cli RPC is open and listening on port 18332

curl --user admin --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/

I can also run docker commands directly using something line docker-cli-js

docker.command('exec 89b35eae3333 lightning-cli --lightning-dir=.lightning getinfo', function (err, data) { console.log('data = ', data); });

Why is this an issue?

This has not been an issue up until now as I have only been interfacing with the Bitcoin CLI (which I do in the way explained above) now I am looking to add Lightning support to my app (and Lightning) which does not seem to have an open port that I can access the way I do with the Bitcoin CLI on port 8332/18332.

Also as I run my application on a different server (so I cannot run the docker commands from inside code) from my cyphernode the only way I can generate Lightning address etc is via the proxy.

I hope the above makes sense and you provide me the really simple answer I missed.

gabidi commented 4 years ago

Hi, Not sure about the particulars of your installation but Cyphernode exposes access to it's services to the outside world via the gatekeeper, which is usually on port 2009, ie you would curl localhost:2009/v0/getactivewatches Do a docker ps and double check what port your gateway container instance maps to on your host.

Also you probably already know this but just to be clear you need to make sure you are sending the correct authorisation bearer token in the header when making a request via the gatekeeper.

Finally it looks like you're writing your app in JS , if so maybe checking out https://github.com/gabidi/cyphernode-js-sdk would help you. Hope that helps.

chrisjmccreadie commented 4 years ago

Hi,

Thanks for that I knew it would be something simple in this case I was missing the v0 I was making calls like this:

https://127.0.0.1:2009/getactivewatches

Thanks for the quick response and that JS SDK looks really cool will be looking into that for sure.

chrisjmccreadie commented 4 years ago

works great

curl -H 'Accept: application/json' -H "Authorization: Bearer 7545XXXXXXXXXXXXXXXXXXXXXXXXXXXXXb3ac8d068b38d88db0a1a4df62a" https://127.0.0.1:2009/v0/getactivewatches