Intermediary RaiBlocks wallet/node communicator. Clients use this server to query or run JSON RPC commands on an XRB node.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Completion: Completion

Intermediary RaiBlocks wallet/node communicator. The goal of this project is to provide an easy to use, multi-platform software layer to communicate with a full RaiBlocks node, especially in such a way as to be able to sustain and run a light wallet.

Rain Logo

Sending and Receiving

RainServer uses a small 5-byte header on every request that it sends and receives. The first byte of the header is a boolean that is only true if the request is a new block notification - so only the server, which is directly connected to the wallet, will be sending them. Any client that sends a request with a header with a first byte that has a non-zero value will be dropped - but the client should be ready at all times to receive these new block notifications. The next four bytes (a signed integer) represent the length of the request, excluding the 5 byte header. Every request that that either the client and server send must have the request length pre-calculated and placed in the header. If this number is wrong, the server will drop the client. By default, the maximum request size that the client may send to the server is 10000 bytes, but this is subject to change. Here is a graphical representation of the first six bytes of a request (the bytes after the first curly bracket are omitted):

Request header example

From the image above we can tell that this message is a server telling a client about a new block with a length of 416 bytes.


  • Find a better way checking if a message has been received over a socket (perhaps a tiny 4 byte content length header on every JSON request) as currently the server checks checks if nothing has been recieved in the last 20ms. Headers are now used.
  • Clean the code and make it more readable
  • Comment all code and methods thoroughly
  • Wiki documentation

Custom Commands

RainServer has a custom command system - these are requests for information from RainServer itself, not the RaiBlocks wallet/node. Currently, there are two implemented commands, the first of which is CommandPrice which returns the price of RaiBlocks that is retreived and updated from CoinMarketCap every two minutes. To return the price, send the following JSON with the appropriate header into your RainServer socket from your client: { "command": "price" }, and you will receive the price back: { "price": "13.37" }. If CoinMarketCap could not be reached, the price will be returned as { "price": "0.00" }. The price is in US Dollars ($). The second command returns the number of users (open sockets) that the RainServer currently has open: { "command": "connectedcount" }, which returns { "connectedcount": "1" }.

Libraries used

  • Gson 2.8.2


Feature Achieved?
Basic functionality Yes
Multiple connections Yes
Command limiting/throttling Yes
Broadcast blocks to clients Yes
Command sanitation Unneeded
Wiki documentation No