Bitcoin Forum
April 25, 2024, 08:53:57 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin Core RPC communication  (Read 97 times)
MixMAx123 (OP)
Full Member
***
Offline Offline

Activity: 161
Merit: 168


View Profile
October 14, 2021, 04: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.
1714078437
Hero Member
*
Offline Offline

Posts: 1714078437

View Profile Personal Message (Offline)

Ignore
1714078437
Reply with quote  #2

1714078437
Report to moderator
1714078437
Hero Member
*
Offline Offline

Posts: 1714078437

View Profile Personal Message (Offline)

Ignore
1714078437
Reply with quote  #2

1714078437
Report to moderator
The network tries to produce one block per 10 minutes. It does this by automatically adjusting how difficult it is to produce blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714078437
Hero Member
*
Offline Offline

Posts: 1714078437

View Profile Personal Message (Offline)

Ignore
1714078437
Reply with quote  #2

1714078437
Report to moderator
1714078437
Hero Member
*
Offline Offline

Posts: 1714078437

View Profile Personal Message (Offline)

Ignore
1714078437
Reply with quote  #2

1714078437
Report to moderator
PrimeNumber7
Copper Member
Legendary
*
Offline Offline

Activity: 1610
Merit: 1899

Amazon Prime Member #7


View Profile
October 14, 2021, 04:49:23 PM
Merited by ABCbits (1), BlackHatCoiner (1)
 #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.
MixMAx123 (OP)
Full Member
***
Offline Offline

Activity: 161
Merit: 168


View Profile
October 14, 2021, 05:43:45 PM
Last edit: October 15, 2021, 02:45:25 AM by achow101
 #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.
PrimeNumber7
Copper Member
Legendary
*
Offline Offline

Activity: 1610
Merit: 1899

Amazon Prime Member #7


View Profile
October 14, 2021, 06: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.
MixMAx123 (OP)
Full Member
***
Offline Offline

Activity: 161
Merit: 168


View Profile
October 14, 2021, 06:08:58 PM
Last edit: October 14, 2021, 06:25:58 PM by MixMAx123
 #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.
j2002ba2
Full Member
***
Offline Offline

Activity: 204
Merit: 437


View Profile
October 14, 2021, 07:58:52 PM
Merited by MixMAx123 (4), ABCbits (3), PrimeNumber7 (1)
 #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}
MixMAx123 (OP)
Full Member
***
Offline Offline

Activity: 161
Merit: 168


View Profile
October 14, 2021, 08:18:27 PM
Last edit: October 14, 2021, 11:14:28 PM by MixMAx123
 #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!!!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!