Access Coin Daemons via RPC

Access XLite Coin Daemons via RPC

If you are doing something like writing a trading bot which trades out of XLite, you may find it useful to have direct access to the individual coin daemons of XLite. The following examples show you how.

Firstly, make sure CloudChains daemon is running

The CloudChains daemon must be running to access the coin daemons of XLite. The easiest way to start the CloudChains daemon running is simply to open XLite and login. Alternatively, you can run CloudChains daemon without opening XLite by following these steps:

  1. Download the CloudChains daemon for your OS
  2. Extract the executable file, Cloudchains-SPV from the .zip download.
  3. Start the CloudChains daemon in a Terminal (Linux, Mac) or Command Prompt (Windows) with Cloudchains-SPV
  4. Select option 2 to have CloudChains daemon use the XLite wallet you created previously when you installed XLite.
  5. Enter your XLite login password when prompted for a password.

Accessing coin daemons via RPC calls

Note: Windows users will need to install curl if it is not already installed.

  1. Navigate to the CloudChains settings directory:

    • Windows:

      C:\Users\[YourUsername]\AppData\CloudChains\settings
      
      Or paste %appdata%\CloudChains\settings into the File Explorer path field.

    • MacOS:

      ~/Library/Application Support/CloudChains/settings
      
      Open Finder and in the program menu select Go > Go to Folder... and enter the above path.

    • Linux:

      ~/.config/CloudChains/settings
      

  2. Extract the RPC login credentials for the coin daemon you want to access. These credentials are found in a file called, config-<coin>.json where <coin> is the coin daemon you want to access. For example, if you want to access the BTC daemon, examine config-BTC.json. It will look something like this:

    {
        "rpcPassword": "8vCaDSpOKJ8ZhJdukZxaU4Z4NGFFDa9mPy1b-ZT6tHA",
        "fee": 0.0001,
        "rpcUsername": "VMvT5inMA0841-458cOxSgz5V0mxJR8J",
        "rpcPort": 8333,
        "feeFlat": true,
        "rpcEnabled": true,
        "addressCount": 40
    }
    

    The RPC login credentials you'll need are the rpcPassword, rpcUsername and rpcPort values in this file. In this example these values are 8vCaDSpOKJ8ZhJdukZxaU4Z4NGFFDa9mPy1b-ZT6tHA, VMvT5inMA0841-458cOxSgz5V0mxJR8J and 8333, respectively.

  3. Open a Terminal window (Mac/Linux) or a Command Prompt (Windows) and issue an RPC access command via curl. Here are some examples of sending listunspent and dumpprivkey commands to an XLite coin daemon:

    • listunspent example (no parameters passed)

      curl -H "Content-Type: application/json" -d '{"method":
      "listunspent", "params": []}'
      http://rpcUsername:[email protected]:rpcPort/
      
      where rpcUsername, rpcPassword and rpcPort are the values found in the previous step.

    • dumpprivkeyexample (one parameters passed)

      curl -H "Content-Type: application/json" -d '{"method":
      "dumpprivkey", "params": ["address"]}'
      http://rpcUsername:[email protected]:rpcPort/
      
      where address is the address for which you want to dump the private key, and rpcUsername, rpcPassword and rpcPort are the values found in the previous step.

    Note: This second example allows you to dump the private keys of particular addresses of particular coins. If you save these private keys in a secure (preferably encrypted) place, you can import them later into the native wallets of those coins. These private keys can thereby act as a kind of backup which will allow you to access your XLite funds, even if XLite itself is down or unavailable for some reason. For example, if you want to access LTC in your XLite and you've dumped the private keys of your LTC in XLite, you can import those private keys at any time into an LTC native wallet. Alternatively, you can import the private keys from XLite into another noncustodial multi-wallet, like Exodus.

  4. The coin daemons of XLite can also be accessed via RPC calls made programmatically (using the RPC login credentials found in step 2 above). Here is an example of a Python program which dumps private keys of XLite addresses.

Troubleshooting

If you encounter issues, please join Blocknet's Discord and ask a question in the #support channel.

Warning: Beware of scams

Be cautious of users sending you private messages on Discord to help with troubleshooting, even if they claim to be team members. Scammers will often prey on those having issues and offer help in an attempt to steal funds. This is usually done by impersonating team members.

XRouter Beta Released! Read more...
Required Wallet Update! View downloads...