Author

Topic: Bitcoin Core RPC communication (Read 102 times)

full member
Activity: 161
Merit: 168
October 14, 2021, 04:18:27 PM
#7
Thank you, hopefully this will take me a step further.

Nevertheless, the bticoin-cli.exe shoots itself again after the start?
Is there a guide on how to run the bitcoin-cli.exe correctly?

----

Finally,
Forget "\ n" in the last line.
Now it's working :-)
Thanks very much!!!
full member
Activity: 204
Merit: 437
October 14, 2021, 03:58:52 PM
#6
bitcoin-cli resides in the same directory as bitcoind and bitcoin-qt

You communicate with port 8332 through HTTP POST, using JSON. The communication is in plaintext.

Example for getbestblockhash:
Code:
POST / HTTP/1.1
Host: 127.0.0.1
Connection: close
Content-Type: application/json
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Length: 49

{"method":"getbestblockhash","params":[],"id":1}
Where "xxx...x" is base64 encoded username:password or the base64 of the content of the .cookie file (__cookie__:...). For example foo:12345 would result in Zm9vOjEyMzQ1.
Please note, that all newlines above are "\r\n", except after the very last line, which is only "\n".

You'd get a result:
Code:
HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 14 Oct 2021 19:28:01 GMT
Content-Length: 98
Connection: close

{"result":"000000000000000000064613309ca3e8232397b467af98790b3cc3ac23479f80","error":null,"id":1}
full member
Activity: 161
Merit: 168
October 14, 2021, 02:08:58 PM
#5
This command could not be found.
Can you please describe where I should enter this?
I have a Windows PC

- Bitcion Core runs in the background on the same PC.


In the end, data is only transmitted in binary form.
To avoid conversion misunderstandings, I would like to know how it is transferred in hexadecimal.

My first problem is that I don't even know whether my RPC connection to my Bitcoin core is working at all. How should I test this?

...

There's a good reason to create your own library.
It is often easier and much faster to create your own library than to familiarize yourself with a poorly documented one.
copper member
Activity: 1624
Merit: 1899
Amazon Prime Member #7
October 14, 2021, 02:04:04 PM
#4
From the command line, you can enter the following:
Code:
bitcoin-cli getblockcount
The above command will return the most recent block height bitcoin core has received and verified as being valid. Bitcoin core must be running on the machine you run the above command from. To my knowledge, there is no way to "ping" via an RPC call.

My understanding is that bitcoin core will only accept RPC calls in base 10 format.

If you want to make programmatic RPC calls, your best bet is to use POST requests to the server running the bitcoin core. Doing this will require you to use a library that can make POST requests. You could theoretically create a library from scratch, but I don't see any reason to recreate something that has already been well tested.
full member
Activity: 161
Merit: 168
October 14, 2021, 01:43:45 PM
#3
Can you explain that to me more detailed?
I just want to make a kind of ping test.
I just want to know if he answers. What exactly do I have to send? Please in hexadecimal!



Here is the documentation for the various RPC commands available to use with bitcoin core.

To make a RPC call, from the command line, you can use bitcoin-cli [command], or you can make a POST request to the server running bitcoin core.

I entered this command in the console, with the error:

Code:
The command "bitcoin-cli" is either wrongly written or
could not be found.




So I'll try to express myself differently again.
Here is a good guide that describes how to communicate with the Bitcoin core via port 8333.

https://coinlogic.wordpress.com/2014/03/09/the-bitcoin-protocol-4-network-messages-1-version/


I am looking for such a manual for communication via port 8332.
Unfortunately I did not find an exact description of this kind in your link either.
copper member
Activity: 1624
Merit: 1899
Amazon Prime Member #7
October 14, 2021, 12:49:23 PM
#2
Here is the documentation for the various RPC commands available to use with bitcoin core.

To make a RPC call, from the command line, you can use bitcoin-cli [command], or you can make a POST request to the server running bitcoin core.
full member
Activity: 161
Merit: 168
October 14, 2021, 12:41:55 PM
#1
I'm looking for a documentation that shows how I communicate with the Bitcoin Core via the RPC interface on the port 8332.
And without using an external library.
I want to know exactly, I want to send if I open a socket to the IP / Port, so that an answer gets.
Best with example in Hexa Decimal.
Unfortunately, I did not find a docummentation.
Jump to: