Skip to content
ChMarina edited this page Jul 23, 2019 · 16 revisions

API

API List

API Reference

status

Getting info on the state of the network where MHC client runs.

Parameters

none

Returns

version - MHC client version

git_hash - hash of the last commit of the repository the current MHC client version is built from

network_tor_name - name and PORT of the torrent used by MHC client

network_proxy_name - name and PORT proxy used by MHC client

network_tor -IP address and PORT torrent used by MHC client

network_proxy - IP address and PORT proxy used by MHC client

allow_state_blocks - if false: state blocks are ignored, if true: state blocks are supported

jrpc_timeout - json rpc running timeout

jrpc_conn_timeout - json-rpc connection timeout

Example

// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"status"}' 0.0.0.0:9999

//Result
{
  "jsonrpc":"2.0",
  "id":1,
  "result":
  {
    "version":"v0",
    "git_hash":"90d216e0206908d80aeaee34b2c1502507e85d21",
    "network_tor_name":"tor.net-main.metahashnetwork.com:5795",
    "network_proxy_name":"proxy.net-main.metahashnetwork.com:9999",
    "network_tor":"139.162.190.134:5795",
    "network_proxy":"139.162.157.232:9999",
    "allow_state_blocks":false,
    "jrpc_timeout":60000,
    "jrpc_conn_timeout":1000
  }
}

Config file

To configure MetaHash FullNode Client you need to use config files. There are special config files for each network:

General config structure

{
  "service":
  {
    "threads": 4, // Number of threads
    "port": 9999 // Port where service accepts requests
  },
  "server":
  {
    "tor": "tor.net-*.metahash.org:5795", // network for reading and sending transactions
    "proxy": "proxy.net-*.metahash.org:9999" // network for reading and sending transactions
  },
  "system":
  {
    "wallets-storage": "./wallets", // Folder for storing wallets
    "blocks_folder": "./blocks/", // Folders for storing a block database
    "leveldb_folder": "./leveldb/",  // Folders for storing a block database
    "validate_blocks": false, // Validate blocks or not
    "use_local_database": true, // Download database or send request to tor servers every time
    "jrpc_conn_timeout": 1000, // json-rpc connection timeout
    "jrpc_timeout": 60000, // json rpc running timeout
    "allow_state_blocks": false // allow to return state blocks
  },
  "extensions":
  {
    "use_tracking_history": false, // flag indicating whether to save transactions or not
    "tracking_history_folder": "./tracking_history" // folder to save transactions in it*
  }
}

*- transactions are saved only for addresses specified in the config file as follows:

{
  "list":
  [
    {"address": "", "last_known": ""},
    ...
  ]
}

where

address - is the address to save transactions for.

last_known - shall be empty, it is used to track last transactions.

This config file containing addresses must be saved in the same folder that is specified in the tracking_history_folder field.

net-dev

{
 "service":
 {
  "threads": 4,
  "port": 9999
 },
 "server":
 {
  "tor": "tor.net-dev.metahash.org:5795",
  "proxy": "proxy.net-dev.metahash.org:9999"
 },
 "system":
 {
  "torrent_server": "tor.net-dev.metahash.org:5795",
  "wallets-storage": "/opt/mhservice/wallet",
  "blocks_folder": "./blocks/",
  "leveldb_folder": "./leveldb/",
  "validate_blocks": false,
  "use_local_database": false,
  "jrpc_conn_timeout": 1000,
  "jrpc_timeout": 60000,
  "allow_state_blocks": false
 }
}

Current config file version: dev-config

net-main

{
 "service":
 {
  "threads": 4,
  "port": 9999
 },
 "server":
 {
  "tor": "tor.net-main.metahashnetwork.com:5795",
  "proxy": "proxy.net-main.metahashnetwork.com:9999"
 },
 "system":
 {
   "torrent_server": "tor.net-main.metahashnetwork.com:5795",
  "wallets-storage": "/opt/mhservice/wallet",
  "blocks_folder": "./blocks/",
  "leveldb_folder": "./leveldb/",
  "validate_blocks": false,
  "use_local_database": false,
  "jrpc_conn_timeout": 1000,
  "jrpc_timeout": 60000,
  "allow_state_blocks": false
 }
}

Current config file version: main-config

net-v8

{
 "service":
 {
  "threads": 4,
  "port": 9999
 },
 "server":
 {
  "tor": "tor.net-v8.metahashnetwork.com:5795",
  "proxy": "proxy.net-v8.metahashnetwork.com:9999"
 },
 "system":
 {
   "torrent_server": "tor.net-v8.metahashnetwork.com:5795",
  "wallets-storage": "/opt/mhservice/wallet",
  "blocks_folder": "./blocks/",
  "leveldb_folder": "./leveldb/",
  "validate_blocks": false,
  "use_local_database": false
 }
}

Current config file version: v8-config

Logging and storing info

When creating wallets in any network main|dev|v8 there will be automatically generated public and private keys for each address and they are stored in directories:

  • net-main

    Directory: /opt/mhp/wallet.main/

    Files are as follows:

    0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.prv - private key for address: 0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c

    0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.pub - public key for address: 0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c

  • net-dev

    Directory: /opt/mhp/wallet.dev/

    Files are as follows:

    0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.prv - private key for address: 0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c

    0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.pub - public key for address: 0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c

  • net-v8

    Directory: /opt/mhp/wallet.v8/

    Files are as follows:

    0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.prv - private key for address: 0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c

    0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.pub - public key for address: 0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c

Key Authorization

For key authorization, there are the following settings in the config file:

"service":
{
  "auth_enable": true, // authorization is enabled or disabled
  "auth_key": "your_key" // authorization key value
}

If there is the auth_enable flag in true, it means that the key authorization is enabled.

Therefore, the X-AUTH-KEY header value sent to the client's http request (for example, X-AUTH-KEY: your_key) will be compared to the auth_key value from the config file and, if the key values match, the authorization is successful.

Signature verification

In order to enable block signature verification while block caching, you need to configure the following fields in the config file:

"system":
{
  "blocks_cache_block_verification": true, //  flag that shows if signature verification is enabled or disabled (true means enabled)
  "cores":[ // array of cores
    "0x0028dd1ca2951fe554ef526d60ff55a64776ee5e033120ca91",
    "0x005140a0ae997aeae77c09d7d4ccf97aa65695a9a1e28812bd",
    "0x0057b301028c5e0c234bb35b611fc8d3d15c797fb39ef768a4",
    "0x0069fce976a40fbd2c894f1fe635255fc16c80bfe17ce65f5e",
    "0x007fce3c1e56c67f963428b3dcdfc4400408918b843d1652ec",
    "0x00a88a888d16a23991e73b4081b745eec0f56cdc7063baa360",
    "0x00f3dc22cbe3519ce94e9bf12145d61789da0bfd26bbdf7999"]
}

Each block will be checked for signatures and their compliance with configuration.