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
363 stars 68 forks source link

Unable to Query for Block-chain Info? #209

Closed TBCode523 closed 3 years ago

TBCode523 commented 3 years ago

This question might be ridiculous, but how come I can't use the url given in the docs for querying data. I used val rpcURL = "http://cyphernode:8888/getblockchaininfo" and this simple querying function to test the API: fun query(url:String){ val response = URL(url).readText() println(response) }, but then I got an exception. Exception in thread "main" java.net.UnknownHostException: cyphernode how do I resolve this?

Kexkey commented 3 years ago

Hi @TBCode523

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

The host cyphernode doesn't really exist on your system. If you want to hit the proxy directly (without going through the auth layer of the gatekeeper), you need to be "inside" the Cyphernode Docker network. The proxy host only exists in there.

If you want to query Cyphernode from outside the secure Docker network, you need to expose the gatekeeper (answer Yes to that question during setup) and supply the required auth token (JWT). See https://github.com/SatoshiPortal/cyphernode/tree/master/doc#manually-test-your-installation-through-the-gatekeeper and https://github.com/SatoshiPortal/cyphernode/tree/master/clients for client examples, as well as the Batcher (https://github.com/SatoshiPortal/batcher) which is a Cypherapp in TypeScript used by Bull Bitcoin in production.

Let me know if that answers your question and if you successfully query the API!