DarkNetSpace Usage and Development Guide

V1.2 (0.7.0.4)

Jan 28th 2015

DarkNetSpace Team

http://darknetspace.org

Introduction

DarkNetSpace is a platform for anonymous applications such as P2P exchange, on-chain shop, Lotto, Gamble, and Bets. DarkNetCoin is the general currency in DarkNetSpace. The ultimate aim of DarkNetSpace is becoming the most private and anonymous platform of crypto-currency applications, the ultimate aim of DarkNetCoin is becoming the general currency of the DarkNet world.

DarkNetSpace is assembled by several components: qt-dnsp the GUI wallet,dnsd the daemon,simplewallet the wallet, connectivity_tool. The following contents will explain the usage and development of these components.

1. GUI wallet Guide (Windows)

  1. Unzip the downloaded package to designated folder.

  2. Double click qt-dnsp.exe to open the wallet, click Wallet after the data was synchronized.

  3. Generate new wallet: Click Wallet tab, then click Generate new wallet to generate a new wallet. The default folder to save the wallet is current folder, you can choose to save to aonther folder as your wish. Modify the file name and click save.

  4. Enter the password, this password is the only credential used to access your wallet and unrecoverable. Note: Be sure to remember your password

  5. File definition:.dnc is the wallet data, .address.txt is the wallet address, .keys is the most important file, don’t lose it.

  6. Open wallet: Click Open Wallet to open a wallet. choose the .dnc or keys file and enter the password.

  7. Wallet interface:Balance: your total balance Unlocked: your available balance can be spent. Send payment: Send the DarkNetCoin to other address. Recent transfers: the recent transaction records.

  8. Transfer: Enter the corresponding address,amount in the Address,Amount input-area, and click Send to transfer. also you can choose More option to bring up more options.

2. Daemon dnsd Usage and Development Guide

dnsd is the blockchain daemon, simplewallet is depends on dnsd to run. It is very easy to launch dnsd, just run dnsd directly.

./dnsd

2.1. Console Command

Command Command Description Command Sample
alia Print all alias
disable_proxy Disable Socks5 proxy
enable_proxy Enable Socks5 proxy enable_proxy <proxy_ip_address> <proxy_port>
getinfo Print many statistics data
height Print the blockchain height
help Show this help
hide_hr Stop showing hash rate
make_alias Puts alias reservation record into block template, if alias is free
print_bc Print blockchain info in a given blocks range print_bc <begin_height> [<end_height>]
print_block Print block print_block <block_hash> | <block_height>
print_cn Print connections
print_pl Print peer list
print_pool Print transaction pool (long format)
print_pool_sh Print transaction pool (short format)
print_tx Print transaction print_tx <transaction_hash>
save Save blockchain
show_hr Start showing hash rate
start_mining Start mining for specified address start_mining <address> [threads=1]
stop_mining Stop mining
tx_stat Calculates transactions statistics

2.2 RPC Interface

There is two RPC interface of dnsd, JSON Interface and BIN Interface. JSON Interface is using JSON to communication, usually used for less demanding real-time remote communications. BIN Interface is using binary data to communication, usually used for high demanding real-time remote and local communications.

2.2.1 JSON

JSON Interface usually uses http://127.0.0.1:37709/ to query the interfaces, the commands are following the URL.
We can use the command like curl -X POST http://127.0.0.1:37709/getheight to test. If there no parameter to post, we can use the browser directly to get the result.

Notice: below are demostration by using curl under LINUX, if you want to use under Windows, please replace " in the data string with \".

2.2.1.1 Get the block height - getheight

RPC Command:http://127.0.0.1:37709/getheight

Input Data:none

Output Result:

{
    "height": 73137,
    "status": "OK"
}
2.2.1.2 Get the specified transaction - gettransactions

RPC Command:http://127.0.0.1:37709/gettransactions

Input Data:

{
    "txs_hashes":["97cccff36cd11c4b8f4dc0dc81fb2442662c4f2c9cafa49f1580609c474e59c"]
}

Output Result:

{ 
    "status": "OK", 
    "txs_as_hex": [],
    "missed_tx":[]
}

txs_as_hex is the transactions list that is found, the format is hexadecimal string. missed_tx is the transaction IDs list that is not found. The return value of status is not OK means error happened, and there is error message.

2.2.1.3 Get the specified transaction - get_transactions

Similar to the previous interface gettransactions, but the difference is the return transaction is JSON format.

RPC Command:http://127.0.0.1:37709/get_transactions

Input Data:

{
    "txs_hashes": [
        "97cccff36cd11c4b8f4dc0dc81fb2442662c4f2c9cafa49f1580609c474e59c",
        "0399f25da8ae73fff4b2ddd93463d189968e3059b8dc65b8967306b781c3fcda"
    ]
}

Output Result:

 { 
     "status": "OK",
     "txs_as_hex": [],
     "missed_tx":[]
 }

txs_as_hex is the transactions list that is found, the format is JSON.

The JSON format of each transactons is shown as follows:

{
    "version": 1,
    "unlock_time": 80061,
    "vin": [
        {
            "gen": {
                "height": 80001
            }
        }
    ],
    "vout": [
        {
            "amount": 400000,
            "target": {
                "key": "63c707badaf0151912408d812098c8b8f42a937532f20060b014ccb5a98d9f0500"
            }
        },
        {
            "amount": 6000000,
            "target": {
                "key": "16eea8ffd98d418e24a78a8ac94020465467b162023a0777d4a76260f9f30b1700"
            }
        },
        {
            "amount": 70000000,
            "target": {
                "key": "60060bf166f6279ecf11e12ed490120f8890b0e5827bfaf9ccee0fc4a06b8e9600"
            }
        },
        {
            "amount": 900000000,
            "target": {
                "key": "8fd00058af39451e82ed4e4e5d516878ab49ab178b747c3fd92d94f9041dd9bd00"
            }
        },
        {
            "amount": 7000000000,
            "target": {
                "key": "8626ce6ec6003e27e675934e81612db577e47c7346b750ae0d4022bc3dfb51a200"
            }
        },
        {
            "amount": 90000000000,
            "target": {
                "key": "a1dfac9db983dbf5b08da1fd69935d04fc64116735e9956b81cea2684972c94a00"
            }
        },
        {
            "amount": 700000000000,
            "target": {
                "key": "e8278e157293077d560821affd29eefcaf9f7b40d7ae58a38dde4c8e26c5b95e00"
            }
        },
        {
            "amount": 8000000000000,
            "target": {
                "key": "5b8097a74b3e72e9fa18a8a2724b68b035e97f4afcb50cfdcf0db4acb8daad3b00"
            }
        },
        {
            "amount": 60000000000000,
            "target": {
                "key": "61397e6cb9b482341998c680428008b88b3cfd95a3dce0b9884865e23519825a00"
            }
        },
        {
            "amount": 6879797640000,
            "target": {
                "key": "e1950b810f6c2da80d96e80975ce8990816137dbde08a6f375006d862c6a56ec00"
            }
        },
        {
            "amount": 764421960000,
            "target": {
                "key": "81af4b7cae885d4ae1199b1002a4ffb9239c67ec64c9df07d453230bd4d0b17e00"
            }
        }
    ],
    "extra": [
        1,
        106,
        220,
        188,
        71,
        105,
        187,
        236,
        197,
        132,
        195,
        67,
        253,
        223,
        5,
        0,
        30,
        174,
        253,
        34,
        45,
        246,
        170,
        235,
        38,
        40,
        111,
        21,
        136,
        15,
        78,
        111,
        9,
        2,
        30,
        48,
        46,
        54,
        46,
        54,
        46,
        49,
        40,
        48,
        46,
        49,
        45,
        103,
        52,
        48,
        98,
        56,
        57,
        102,
        48,
        41,
        0,
        0,
        0,
        6,
        79,
        169,
        114,
        25,
        0
    ],
    "signatures": [],
    "tx_hashes": []
}

missed_tx is the transaction IDs list that are not found. The return value of status is not OK means error happened, and there is error message.

2.2.1.4 Get the transactions list in memory pool - get_tx_pool

RPC Command:http://127.0.0.1:37709/get_tx_pool

Input Data: none

Output Result:

{
    "status": "OK",
    "txs": []
}

txs is the detail of transaction in JSON format, the format is same as 2.2.1.3. The return value of status is not OK means error happened, and there is error message.

2.2.1.5 Get the block list by height - get_blocks_by_heights

RPC Command:http://127.0.0.1:37709/get_blocks_by_heights

Input Data:

{
    "start_height": 80000,
    "blocks_count": 3,
    "genesis_hash": "aecf5933feeaf47857d096f82d97de644a25dfa63c47c0118c349d4385400f80"
}

definition:

start_height: Start block heigh of the range.
blocks_count: The counts of wanted blocks, don’t exceed 100 blocks.
genesis_hash: The HASH of genesis block.

Output Result:

{
    "status": "OK",
    "blocks_count": 0,
    "quot;blocks": [
        {
            "block": "",
            "txs": []
        },
        {
            "block": "",
            "txs": []
        }
    ]
}

blocks_count the returned blocks counts.
blocks is the list of blocks details including block header, miner transaction, other transaction. The txs may not be in blocks

The JSON format of block is shown as follows:

{
    "major_version": 1,
    "nonce": 2185365362,
    "prev_id": "d3855e2a339fdf5934e20d5dd397b1a271537e98bd8ae6e144b419dd2da22519",
    "minor_version": 0,
    "timestamp": 1417934844,
    "flags": 0,
    "miner_tx": {
        "version": 1,
        "unlock_time": 80061,
        "vin": [
            {
                "gen": {
                    "height": 80001
                }
            }
        ],
        "vout": [
            {
                "amount": 400000,
                "target": {
                    "key": "63c707badaf0151912408d812098c8b8f42a937532f20060b014ccb5a98d9f0500"
                }
            },
            {
                "amount": 6000000,
                "target": {
                    "key": "16eea8ffd98d418e24a78a8ac94020465467b162023a0777d4a76260f9f30b1700"
                }
            },
            {
                "amount": 70000000,
                "target": {
                    "key": "60060bf166f6279ecf11e12ed490120f8890b0e5827bfaf9ccee0fc4a06b8e9600"
                }
            },
            {
                "amount": 900000000,
                "target": {
                    "key": "8fd00058af39451e82ed4e4e5d516878ab49ab178b747c3fd92d94f9041dd9bd00"
                }
            },
            {
                "amount": 7000000000,
                "target": {
                    "key": "8626ce6ec6003e27e675934e81612db577e47c7346b750ae0d4022bc3dfb51a200"
                }
            },
            {
                "amount": 90000000000,
                "target": {
                    "key": "a1dfac9db983dbf5b08da1fd69935d04fc64116735e9956b81cea2684972c94a00"
                }
            },
            {
                "amount": 700000000000,
                "target": {
                    "key": "e8278e157293077d560821affd29eefcaf9f7b40d7ae58a38dde4c8e26c5b95e00"
                }
            },
            {
                "amount": 8000000000000,
                "target": {
                    "key": "5b8097a74b3e72e9fa18a8a2724b68b035e97f4afcb50cfdcf0db4acb8daad3b00"
                }
            },
            {
                "amount": 60000000000000,
                "target": {
                    "key": "61397e6cb9b482341998c680428008b88b3cfd95a3dce0b9884865e23519825a00"
                }
            },
            {
                "amount": 6879797640000,
                "target": {
                    "key": "e1950b810f6c2da80d96e80975ce8990816137dbde08a6f375006d862c6a56ec00"
                }
            },
            {
                "amount": 764421960000,
                "target": {
                    "key": "81af4b7cae885d4ae1199b1002a4ffb9239c67ec64c9df07d453230bd4d0b17e00"
                }
            }
        ],
        "extra": [
            1,
            106,
            220,
            188,
            71,
            105,
            187,
            236,
            197,
            132,
            195,
            67,
            253,
            223,
            5,
            0,
            30,
            174,
            253,
            34,
            45,
            246,
            170,
            235,
            38,
            40,
            111,
            21,
            136,
            15,
            78,
            111,
            9,
            2,
            30,
            48,
            46,
            54,
            46,
            54,
            46,
            49,
            40,
            48,
            46,
            49,
            45,
            103,
            52,
            48,
            98,
            56,
            57,
            102,
            48,
            41,
            0,
            0,
            0,
            6,
            79,
            169,
            114,
            25,
            0
        ],
        "signatures": []
    },
    "tx_hashes": []
}

txs is the transactions list, the format is same as 2.2.1.3.

2.2.1.6 Send the transaction - sendrawtransaction

RPC Command:http://127.0.0.1:37709/sendrawtransaction

Input Data:

{
    "tx_as_hex": "c12a7030eaf7e336e54a2d1b62c9c216cebfb34398d6371d3ea83ec8e1bd91b"
}

Input Data:tx_as_hex is the tranactions data store as hexadecimal string.

Output Result:

{
    "status": "OK"
}
2.2.1.7 Start mining - start_mining

RPC Command:http://127.0.0.1:37709/start_mining

Input Data:

{
    "miner_address": "D4GyKPd9Qg8eEFYgAeab86Hivr9HrMcSMR4MnQmM7wAmKjz7Fuiu9wbWCb37PGCkLkSSRRmjGG7cuThb8BgLK4beT4bDiMw",
    "thread": "1"
}

definition:

miner_address:Miner wallet address

thread:Threads count

Output Result:

{
    "status": "OK"
}
2.2.1.8 Stop mining - stop_mining

RPC Command:http://127.0.0.1:37709/stop_mining

Input Data: none

Output Result:

{
    "status": "OK"
}
2.2.1.9 Get network status - getinfo

RPC Command:http://127.0.0.1:37709/getinfo

Input Data: none

Output Result:

{
    "alias_count": 16,
    "alt_blocks_count": 0,
    "current_blocks_median": 30000,
    "current_network_hashrate_350": 2262006334,
    "current_network_hashrate_50": 2435368275,
    "daemon_network_state": 2,
    "difficulty": 137300603865,
    "grey_peerlist_size": 82,
    "height": 73137,
    "incoming_connections_count": 28,
    "max_net_seen_height": 0,
    "mi": {
        "build_no": 0,
        "mode": 0,
        "ver_major": 0,
        "ver_minor": 0,
        "ver_revision": 0
    },
    "outgoing_connections_count": 5,
    "scratchpad_size": 31065728,
    "status": "OK",
    "synchronization_start_height": 0,
    "transactions_cnt_per_day": 829,
    "transactions_volume_per_day": 1068648337000000000,
    "tx_count": 46278,
    "tx_pool_size": 3,
    "white_peerlist_size": 35
}

2.2.2 JSON_RPC

JSON_RPC are used with /json_rpc, mostly used on mining.

RPC Command:http://127.0.0.1:37709/json_rpc 

Input data is shown as follows:

{
    "jsonrpc": "2.0",
    "id": "test",
    "method": "getblockcount",
    "params": []
}

id can be specified as your wish. method is the methods will be explained as follows. params is the parameter with each method. params can be set to empty if there is no parameter.

Output format looks like:

{
    "id": "test",
    "jsonrpc": "2.0",
    "result": {
        "count": 73174,
        "status": "OK"
    }
}

result is the output result. status is OK means returned correctly, otherwise error occured.

We can use curl -X POST http://127.0.0.1:37709/json_rpc -d to test all of the interfaces, if you want to use under Windows, please replace " in the data string with \".

2.2.2.1 Get block height - getblockcount

Input data:

{
    "jsonrpc": "2.0",
    "id": "test",
    "method": "getblockcount"
}

Output result:

{
    "id": "test",
    "jsonrpc": "2.0",
    "result": {
        "count": 73174,
        "status": "OK"
    }
}
2.2.2.2 Get the hash value of specified height - on_getblockhash

Input data:

{
    "jsonrpc": "2.0",
    "id": "test",
    "method": "on_getblockhash",
    "params": {
        "height": 27894
    }
}

Output result:

{
    "id": "test",
    "jsonrpc": "2.0",
    "result": "5b786d239d218f63e3542b9e983be73828b035e8ffdc4ad19ce30fc71eb9826f"
}
2.2.2.3 Get the template of block - getblocktemplate

Input data:

{
    "jsonrpc": "2.0",
    "id": "test",
    "method": "getblocktemplate",
    "params": {
        "reserve_size": 200,
        "wallet_address": "D4Jyd47oagvJwNrnc2hmRTZdm9SwRd2XiHqVFkGuuf2yNdRtDQAeHJSEGfqx2YYpn6Zut1uSWYrYrhPCRnwvV6gmSnDpAtc"
    }
}

Output result:

{
    "id": "test",
    "jsonrpc": "2.0",
    "result": {
        "blocktemplate_blob": "010000000000000000467c9a46dd7b40113ef290532f1bfd206867438e753c9a0dc9706167fc6a553000f4dcf5a305000187ba0401ffcbb9040b80b51802010efb9111608d38a35392e44615231289cf2879751ac032a00302f653b9be4300809bee0202411bb46fa770c85e1e496fc1f1650f7228267f4a8091f26b309c68738fab9e6f0080b48913024d222080ecd6ceeb5add88fcbfc6878d2d88bfa440ead5eab5285ddb6ebdd15e0080c2d72f02d1c4f340f01cf1b68283c45aa46e323a9b62e5418bfe2e3c1a9ebc2ac9a521430080d0acf30e027719b614d0bd73229c86e3012aacb07ae3c33743cf467bacf20cceb79ce3c143008090dfc04a028685e17199590a00478258c14a71b0cbdb7818dcd052d84dd7f85ce6dddebaa20080e0a596bb1102f19fb7af89b82b7b0270f3b1a96cc53a16583ff5e44cd4c9b6625d76deffb1540080c0a8ca9a3a02f46886db803b2aaf8172d7639bcb06c56d70110114014cfdfc34154236b6b1d80080c089a9a2f50f025849511c77e484e1c57fb353d95be34abb06e978a1d2aef8908f2ad22664625b0080a794cdaed3010204630aac829b741ee8c2a24d880181ae35493394ba25e7b7f72ead3016743e3b0080afc988be1702ba0bc82180635b994212bd4ae7597fa415928afd4d612eca6d04941094e968d600810201ed81936f2763872638d0a71cef7aee28daa9e27f53e98a925feecd7d186b575502de302e362e362e3128302e312d6734306238396630290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "difficulty": 133796655084,
        "height": 72907,
        "reserved_offset": 548,
        "status": "OK"
    }
}
2.2.2.4 Submit block - submitblock

Input data:

{
    "jsonrpc": "2.0",
    "id": "test",
    "method": "submitblock",
    "params": [
        "0100...."
    ]
}

Output result:

{
    "id": "test",
    "jsonrpc": "2.0",
    "result": {
        "status": ""
    }
}
2.2.2.5 Get the last block header - getlastblockheader

Input data:

{
  "jsonrpc": "2.0",
  "id" : "test",
  "method": "getlastblockheader"
}

Output result:

{
  "id": "test",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "depth": 0,
      "difficulty": 133724167762,
      "hash": "8259c5a6246d7ef6354725b3e62ad15783d20bdcab02d30b49942569e71b3e7e",
      "height": 72913,
      "major_version": 1,
      "minor_version": 0,
      "nonce": 2153013099,
      "orphan_status": false,
      "prev_hash": "2349ad96994efb52ae6bd56a6f446039636f521f1e1a79105ab92233668574ad",
      "reward": 80752802000000,
      "timestamp": 1417506962
    },
    "status": "OK"
  }
}
2.2.2.6 Get the block header by hash - getblockheaderbyhash

Input data:

{
  "jsonrpc": "2.0",
  "id" : "test",
  "method": "getblockheaderbyhash",
  "params": {
    "hash" : "8259c5a6246d7ef6354725b3e62ad15783d20bdcab02d30b49942569e71b3e7e "
  }
}

Output result:

{
  "id": "test",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "depth": 5,
      "difficulty": 133724167762,
      "hash": "8259c5a6246d7ef6354725b3e62ad15783d20bdcab02d30b49942569e71b3e7e",
      "height": 72913,
      "major_version": 1,
      "minor_version": 0,
      "nonce": 2153013099,
      "orphan_status": false,
      "prev_hash": "2349ad96994efb52ae6bd56a6f446039636f521f1e1a79105ab92233668574ad",
      "reward": 80752802000000,
      "timestamp": 1417506962
    },
    "status": "OK"
  }
}
2.2.2.7 Get the block hader by height - getblockheaderbyheight

Input data:

{
  "jsonrpc": "2.0",
  "id" : "test",
  "method": "getblockheaderbyheight",
  "params": {
    "height" : 72893
  }
}

Output result:

{
  "id": "test",
  "jsonrpc": "2.0",
  "result": {
    "block_header": {
      "depth": 28,
      "difficulty": 132949309870,
      "hash": "a30ba1b3fe7e525d13820133841b3194ec5772fa6715a5da7e2c55614e305828",
      "height": 72893,
      "major_version": 1,
      "minor_version": 0,
      "nonce": 3642722453,
      "orphan_status": false,
      "prev_hash": "1f439c5e2ae6164e498e6cf09d3f957de693729153af2c65de318063889d1329",
      "reward": 80702116000000,
      "timestamp": 1417505776
    },
    "status": "OK"
  }
}
2.2.2.8 Get the detail of all alias - get_all_alias_details

Input data:

{
"id": 0,
"jsonrpc":"2.0",
"method":"get_all_alias_details", 
"params":{}
}

Output result:

{
  "id": 0,
  "jsonrpc": "2.0",
  "result": {
    "aliases": [{
      "address": "DBFvyhGzEo6FqheGUMVaBM56crUeRvPQzVrDXLMJytGH481WsL5PSmXJq2evy1BsPF9zyg9VsNr2BhdgTCQ7Q8mqQsmjxG9",
      "alias": "darknetspace",
      "comment": "darknetspace",
      "tracking_key": ""
    },{
      "address": "DBFvyhGzEo6FqheGUMVaBM56crUeRvPQzVrDXLMJytGH481WsL5PSmXJq2evy1BsPF9zyg9VsNr2BhdgTCQ7Q8mqQsmjxG9",
      "alias": "darknetcoin",
      "comment": "darknetcoin",
      "tracking_key": ""
    }
],
    "status": "OK"
  }
}
2.2.2.9 Get the detail of specified alias - get_alias_details

Input Data:

{
"id": 0,
"jsonrpc":"2.0",
"method":"get_alias_details", 
"params":"alias": "darknetspace"
}

Output result:

{
  "id": 0,
  "jsonrpc": "2.0",
  "result": {
    "alias_details": {
      "address": "DBFvyhGzEo6FqheGUMVaBM56crUeRvPQzVrDXLMJytGH481WsL5PSmXJq2evy1BsPF9zyg9VsNr2BhdgTCQ7Q8mqQsmjxG9",
      "comment": "darknetspace",
      "tracking_key": ""
    },
    "status": "OK"
  }
}
2.2.2.10 Get alias by specified address - get_alias_by_address

Input Data:

{
"id": 0,
"jsonrpc":"2.0",
"method":"get_alias_by_address", 
"params":"DBFvyhGzEo6FqheGUMVaBM56crUeRvPQzVrDXLMJytGH481WsL5PSmXJq2evy1BsPF9zyg9VsNr2BhdgTCQ7Q8mqQsmjxG9"
}

Output result:

{
  "id": 0,
  "jsonrpc": "2.0",
  "result": {
    "alias": "darknetspace",
    "status": "OK"
  }
}
2.2.2.11 Get addendums - get_addendums

Input Data:

{
"id": 0,
"jsonrpc":"2.0",
"method":"get_addendums", 
"params":{}
}

Output result:

{
  "id": 0,
  "jsonrpc": "2.0",
  "result": {
    "status": "OK"
  }
}

2.2.3 BIN Interface

This is the BIN interface of RPC interface. All of the input and output parameters are binary data, these commands of BIN interface are suffixed with .bin, mostly used with real-time and efficient C/C++ interface.

All of the input datas are using storage_block_header as init data:

struct storage_block_header
{
       uint32_t m_signature_a;
uint32_t m_signature_b;
uint8_t  m_ver;
};

In DarkNetSpace, these data are constant.

#define PORTABLE_STORAGE_SIGNATUREA 0x01011101
#define PORTABLE_STORAGE_SIGNATUREB 0x01020101 // bender's nightmare 
#define PORTABLE_STORAGE_FORMAT_VER 1

m_signature_a = PORTABLE_STORAGE_SIGNATUREA;
m_signature_b = PORTABLE_STORAGE_SIGNATUREB;
m_ver = PORTABLE_STORAGE_FORMAT_VER;
2.2.3.1 Get all output data of specified transaction - get_o_indexes.bin

RPC Command:http://127.0.0.1:37709/get_o_indexes.bin

Input Data: hash value of transaction

  crypto::hash txid;

Output Result:

  std::vector<uint64_t> o_indexes;
  std::string status;

o_indexes is the indexed output list of this transaction.

Data struct is shown as follows:

struct COMMAND_RPC_get_TX_GLOBAL_OUTPUTS_INDEXES
  {
    struct request
    {
      crypto::hash txid;
      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE_VAL_POD_AS_BLOB(txid)
      END_KV_SERIALIZE_MAP()
    };
    struct response
    {
      std::vector<uint64_t> o_indexes;
      std::string status;
      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE(o_indexes)
        KV_SERIALIZE(status)
      END_KV_SERIALIZE_MAP()
    };
  };
2.2.3.2 Get the the transactions list in the memory pool - get_tx_pool.bin

This command is same as get_tx_pool of the JSON interface, only diffrence is BIN interface.

RPC Command:http://127.0.0.1:37709/get_tx_pool.bin

Input Data: none

Output Result:

  std::list<blobdata> txs;  //transactions blobs
  std::string status;

txs is the transaction list output as hexadecimal.

Data struct is shown as follows:

struct COMMAND_RPC_get_TX_POOL
  {
    struct request
    {
      BEGIN_KV_SERIALIZE_MAP()
      END_KV_SERIALIZE_MAP()
    };
    struct response
    {

      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE(txs)
        KV_SERIALIZE(status)
      END_KV_SERIALIZE_MAP()
    };
  };
2.2.3.3 Get the block detail by specified height - getblocks.bin

This command is same as get_blocks_by_heights of the JSON interface, only diffrence is BIN interface.

RPC Command:http://127.0.0.1:37709/getblocks.bin

Input Data:

std::list<crypto::hash> block_ids;

The first ten IDs must be ordered and followed by pow(2,n), like 2,4,8,16,32,64....
The last must be the genesis block due to verify the accuracy of the block request.

Output Result:

std::list<block_complete_entry> blocks;
uint64_t    start_height;
uint64_t    current_height;
std::string status;

start_height is the start height.
current_height is the current height.
blocks is the block data including block header and transactions.

Data struct is shown as follows:

  struct COMMAND_RPC_get_BLOCKS_FAST
  {
    struct request
    {
std::list<crypto::hash> block_ids; 
      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE_CONTAINER_POD_AS_BLOB(block_ids)
      END_KV_SERIALIZE_MAP()
    };
    struct response
    {
      std::list<block_complete_entry> blocks;
      uint64_t  start_height;
      uint64_t  current_height;
      std::string status;
      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE(blocks)
        KV_SERIALIZE(start_height)
        KV_SERIALIZE(current_height)
        KV_SERIALIZE(status)
      END_KV_SERIALIZE_MAP()
    };
  };
2.2.3.4 Get the the random output list by specified amount - getrandom_outs.bin

RPC Command:http://127.0.0.1:37709/getrandom_outs.bin

Input Data:

  std::list<uint64_t> amounts;
  uint64_t          outs_count;
  bool              use_forced_mix_outs;

amounts is the list of amounts.
outs_count is the count of demanded output.
use_forced_mix_outs is the counts of forced mixin.

Output Result:

  std::vector<outs_for_amount> outs;
  std::string status;

outs is the output lists.

Data struct is shown as follows:

struct COMMAND_RPC_get_RANDOM_OUTPUTS_FOR_AMOUNTS
  {
    struct request
    {
      std::list<uint64_t> amounts;
      uint64_t          outs_count;
      bool              use_forced_mix_outs;
      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE(amounts)
        KV_SERIALIZE(outs_count)
        KV_SERIALIZE(use_forced_mix_outs)
      END_KV_SERIALIZE_MAP()
    };

#pragma pack (push, 1)
    struct out_entry
    {
      uint64_t global_amount_index;
      crypto::public_key out_key;
    };
#pragma pack(pop)

    struct outs_for_amount
    {
      uint64_t amount;
      std::list<out_entry> outs;

      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE(amount)
        KV_SERIALIZE_CONTAINER_POD_AS_BLOB(outs)
      END_KV_SERIALIZE_MAP()
    };
    struct response
    {
      std::vector<outs_for_amount> outs;
      std::string status;
      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE(outs)
        KV_SERIALIZE(status)
      END_KV_SERIALIZE_MAP()
    };
  };
2.2.3.5 Set the developer maintenance information - set_maintainers_info.bin

This command is used by DarkNetSpace team to boardcast some important information.

RPC Command:http://127.0.0.1:37709/set_maintainers_info.bin

Input Data:

nodetool::maintainers_entry

Output Result:

std::string status;

Data struct is shown as follows:

struct COMMAND_RPC_SET_MAINTAINERS_INFO
  {
    typedef nodetool::maintainers_entry request;
    struct response
    {
      std::string status;
      BEGIN_KV_SERIALIZE_MAP()
        KV_SERIALIZE(status)
      END_KV_SERIALIZE_MAP()
    };
  };

nodetool::maintainers_entry Data struct is shown as follows:

struct alert_condition
  {
    uint32_t if_build_less_then; //apply alert if build less then
    uint8_t  alert_mode;

    BEGIN_KV_SERIALIZE_MAP()
      KV_SERIALIZE_N(if_build_less_then, "build")
      KV_SERIALIZE_N(alert_mode, "mode")
    END_KV_SERIALIZE_MAP()  
  };
  struct maintainers_info
  {
    uint64_t timestamp;
    /*actual version*/
    uint8_t  ver_major;
    uint8_t  ver_minor;
    uint8_t  ver_revision;
    uint32_t build_no;
    /*conditions for alerting*/
    std::list<alert_condition> conditions;

    BEGIN_KV_SERIALIZE_MAP()
      KV_SERIALIZE_N(timestamp, "ts")
      KV_SERIALIZE_N(ver_major, "maj")
      KV_SERIALIZE_N(ver_minor, "min")
      KV_SERIALIZE_N(ver_revision, "rev")
      KV_SERIALIZE_N(build_no, "build")
      KV_SERIALIZE_N(conditions, "cs")
    END_KV_SERIALIZE_MAP()
  };
  struct maintainers_entry
  {
    blobdata maintainers_info_buff;
    crypto::signature sign;
    BEGIN_KV_SERIALIZE_MAP()
      KV_SERIALIZE(maintainers_info_buff)
      KV_SERIALIZE_VAL_POD_AS_BLOB(sign)
    END_KV_SERIALIZE_MAP()
  };

3. Simplewallet Usage and Development Guide

simplewallet is the wallet of CN series cryptocurrencies, In order to run simplewallet, you have to run dnsd and finish the network synchronization at first.

There are two running methods for simplewallet: Command Line Mode and RPC Mode.

3.1 Command Line Mode

Command line mode means you can use the command line to interactive, the following are examples.

Generate a wallet named with test.dnc under Linux, the test.dnc and 123456 are variable.

./simplewallet --generate-new-wallet test.dnc - password 123456

Open a exist wallet under Linux:

./simplewallet --wallet-file test.dnc --password 123456

Enter help to view all available commands.

Command Command Description Command Sample
address Show current wallet public address
balance Show current wallet balance
bc_height Show blockchain height
change_password Change the password of current wallet change_password <old_password> <new_password>
help Show this help
incoming_transfers - Show incoming transfers - all of them or filter them by availability incoming_transfers [available|unavailable]
list_recent_transfers list_recent_transfers - Show recent maximum 1000 transfers
make_alias pay 101 DNC to miners to make an alias. make_alias <alias> [comment] [viewkey]
payments - Show payments <payment_id_1>, … <payment_id_N> payments <payment_id_1> [<payment_id_2> … <payment_id_N>]
refresh Resynchronize transactions and balance
save Save wallet synchronized data
set_log Change current log detalization level, <level> is a number 0-4 set_log <level>
start_mining Start mining in daemon start_mining <threads_count>
stop_mining Stop mining in daemon
transfer Transfer <amount_1>,… <amount_N> to <address_1>,… <address_N>, respectively. <mixin_count> is the number of transactions yours is indistinguishable from (from 0 to maximum available) transfer <mixin_count> <addr_1> <amount_1> [<addr_2> <amount_2> … <addr_N> <amount_N>] [payment_id]

3.2 RPC Mode

RPC Mode can not input command, but can be operated by RPC command, very suit for mining pools and exchanges.

Enter RPC Mode under Linux, the port 37710 is variable.

./simplewallet --wallet-file test.dnc --password 123456 rpc-bind-port 37710

RPC Interface:http://localhost:37710/json_rpc, interactiving with JSON data.

3.2.1 Get the balance of current account - getbalance

getbalance command gets the balance of current account including total balance and available balance.

Input Data:

{
    "jsonrpc": "2.0", 
    "method": "getbalance", 
    "params": {}
}

Output Result:

{
  "id": 0,
     "jsonrpc": "2.0",
  "result": {
    "balance": 29540782235038289,
    "unlocked_balance": 28814612946038289
}

balance is total balance.
unlocked_balance is available balance.
total balance = balance*10-10=2954078.2235038289

available balance = unlocked_balanc *10-10=288146.12946038289

3.2.2 Transfer the currency - transfer

transfer is sending currency to specified address. payment_id is optional, it is a 32bit hash value if necessary. amount is the amount of currency, amount *10-10 is the actual amout in currency. fee is the transfer fee, fee *10-10 is the actual fee in currency. mixin is mixed times, 0 is no mix. n is mix n times. unlock_time is unlock time, the receiver have to wait the time passed to use the currency.

Input Data:

{
    "jsonrpc": "2.0",
    "method": "transfer",
    "params": {
        "destinations": [
            {
                "amount": 11111,
                "address": "D4Jyd47oagvJwNrnc2hmRTZdm9SwRd2XiHqVFkGuuf2yNdRtDQAeHJSEGfqx2YYpn6Zut1uSWYrYrhPCRnwvV6gmSnDpAtc"
            }
        ],
        "payment_id": "",
        "fee": 1000000000,
        "mixin": 0,
        "unlock_time": 0
    }
}

Output Result:

{
    "id": 0,
    "jsonrpc": "2.0",
    "result": {
        "tx_hash": "<19907e8e2354718a80bd7315bdf78228662cde226e39e3c19012208132209601>"
    }
}

Wrong output (incorrect address)

{
    "error": {
        "code": -2,
        "message": "WALLET_RPC_ERROR_CODE_WRONG_ADDRESS: D4Jyd47oagvJwNrnc2hmRTZdm9SwRd2XiHqVFkGuuf2yNdRtDQAeHJSEGfqx2YYpn6Zut1uSWYrYrhPCRnwvV6gmSnDpAt"
    },
    "id": 0,
    "jsonrpc": "2.0"
}

Wrong output(incorrect fee)

{
    "error": {
        "code": -4,
        "message": "transaction was rejected by daemon"
    },
    "id": 0,
    "jsonrpc": "2.0"
}

3.2.3 Save the wallet data - store

Save the synchronized wallet data to local storage.

Input Data:

{
    "jsonrpc": "2.0",
    "method": "store",
    "params": {}
}

3.2.4 Get the payment data by specified payment id - get_payments

get_payments is used to get the payment data by specified payment_id.

Input Data:

{
    "jsonrpc": "2.0",
    "method": "get_payments",
    "params": {
        "payment_id": "739de437a01cb18fdfa2af63e9fbb9eae7873bebf159a0187a37f0e645b537ea"
    }
}

Output Result:

{
    "id": 0,
    "jsonrpc": "2.0",
    "result": {
        "payments": [
            {
                "amount": 100000000000,
                "block_height": 85711,
                "tx_hash": "52778f573a7d969c72b0959b67703605b63aadc14e7da9689529dff3e6431656",
                "unlock_time": 0
            }
        ]
    }
}

It returned transaction hash, amount, block height, unlock_time.

3.2.5 Get the address of current wallet - getaddress

getaddress is used to get the address of current wallet.

Input Data:

{
    "jsonrpc": "2.0",
    "method": "getaddress",
    "params": {}
}

Output Result:

{
    "id": 0,
    "jsonrpc": "2.0",
    "result": 
    {
        "address":"D4Jyd47oagvJwNrnc2hmRTZdm9SwRd2XiHqVFkGuuf2yNdRtDQAeHJSEGfqx2YYpn6Zut1uSWYrYrhPCRnwvV6gmSnDpAt"
    }
}

3.2.6 Get the last transactions - get_incoming_tx

Starting form ver 0.6.8.3版

Get a specified numbered trasactions list from specified transaction id. Note: the acquired transactions have at least a confirmation, unconfirmed transactions can not be acquired by this interface.

Input Data:

{
    "jsonrpc": "2.0",
    "method": "get_incoming_tx",
    "params": {
        "tx_start_index": 0,
        "tx_get_count":100
    }
}

tx_start_index is the transaction id from start, these ids are started from 0 and ordered by transaction time.
tx_get_count is how many transactions to get. above input data means: get the 100 transactions from 0. tx_get_count can be set to 0 to get all transactions from the start id.

If there is too many transactions (like 10000 transactions) in the wallet, you can get the transaction by split them in pages, for example: get 0-999, then 1000-1999 and so on. Also you can acquire the list with a time interval by record the last transaction id and number of transactions needs to acquire.

Output Result:

{
    "id": 0,
    "jsonrpc": "2.0",
    "result": {
        "tx_get_count":100
        "incoming_txs": [
            {
                "amount": 100000000000,
                "block_height": 85711,
                "tx_hash": "52778f573a7d969c72b0959b67703605b63aadc14e7da9689529dff3e6431656",
                "unlock_time": 0,
                "timestamp":0,  
                "payment_id": 
        "739de437a01cb18fdfa2af63e9fbb9eae7873bebf159a0187a37f0e645b537ea"
            },
            {
                "amount": 100000000000,
                "block_height": 85712,
                "tx_hash": "19907e8e2354718a80bd7315bdf78228662cde226e39e3c19012208132209601",
                "unlock_time": 0,
                "timestamp":0,  
                "payment_id": ""
            }
        ]
    }
}

tx_get_count is the total transactions count of current wallet.
incoming_txs is transaction detail array ordered by transaction’s generated time.

Wrong output data(tx_start_index exceed total transactions count)

{
    "error": {
        "code": -4,
        "message": "Transaction start index should be within 0 to 50"
    },
    "id": 0,
    "jsonrpc": "2.0"
}

4. Application Scenarios

4.1 Node

The node server only need to run dnsd, it will synchronize with the network automaticly.

  1. Ubuntu

    wegt http://www.darknetspace.org/files/DarkNetSpace_Ubuntu64.zip
    unzip DarkNetSpace_Ubuntu64.zip
    cd DarkNetSpace_Ubuntu64
    screen S dnsd
    ./dnsd
    
  2. Windows

    Download from http://www.darknetspace.org/download.html (32bit,64bit)
    Decompress and launch dnsd.exe
    

4.2 Exchange

Wallet Policy: only one wallet address. use payment_id to identify the user deposit. payment_id is a 32bit hash value generated by the exchange. The user enter the payment_id in the wallet when deposting. Exchange can use the RPC command get_payment to get the transactions of specified payment_id.

  1. Run dnsd and synchronize with the network
    It has better to use screen -S dnsd open a new window then run dnsd, press CTRL+A+D to disconnect with the window after dnsd done the sync. dnsd is still running in the background.

  2. Generate and synchronize wallet
    Generate a wallet named with test.dnc under Linux, the test.dnc and 123456 are variable.

    ./simplewallet --generate-new-wallet test.dnc - password 123456
    

    simplewallet will synchronize the wallet with dnsd, use save to save synchronized data after the synchronous done. use exit to exit.

    Generated wallet has three files: .dnc is the wallet data, it will need time to synchronize again if deleted. .address.txt is the wallet address, .keys is the most important file, don’t lose it.

  3. Run simplewallet with RPC Mode

  4. Use screen -S wallet to open a new window then run simplewallet.

    ./simplewallet --wallet-file test.dnc --password 123456 --rpc-bind-port 37710
    

    press CTRL+A+D to disconnect with the window. simplewallet is still running in the background.

    simplewallet will synchronize block data automatic in RPC Mode, but it does not save synchronized data. You have to save the synchronized data by time interval. please review store command in RPC Mode chapter.

  5. Invoke RPC
    RPC Interface: http://localhost:37710/json_rpc, interactive with JSON data.

    review RPC Interface in chapter 3.2

4.3 Mining Pool

System requirement: minimum 2 CPU / 4GB RAM / 20GB HDD, recommend 4 CPU / 8GB RAM / 50GB HDD

The follows are the commands to build a mining pool. The installation can be done without sequentially. Running must be in accordance with the order.

  1. install redis

    wget http://redis.googlecode.com/files/redis-2.6.13.tar.gz 
    tar xzf redis-2.6.13.tar.gz 
    cd redis-2.6.13 
    make 
    make install
    
  2. install httpd

    apt-get install lighttpd
    modify the "lighttpd.conf" web root to "/var/www" in "/etc/lighttpd/"
    
  3. install node:

    sudo apt-get install git-core build-essential curl libcurl4-openssl-dev
    git clone  https://github.com/joyent/node.git
    cd node && ./configure && make
    make install
    
  4. install pool:

    git clone https://github.com/CryptoCoinLabs/node-cryptonote-pool.git
    cd node-cryptonote-pool
    vi config.json    // modify IP and wallet address
    cd example_website
    cp -R *.* /var/www
    
  5. install dnsd

  6. Running:

    1. Run dnsd

      screen S dnsd
      ./dnsd
      Ctrl + A + D
      
    2. Run redis

      screen S redis
      ./redis-server
      Ctrl + A + D
      
    3. Run wallet

      screen S wallet 
      ./simplewallet --generate-new-wallet pool.bin --password 12345678 
      ./simplewallet --wallet-file pool.bin --password 12345678 --rpc-bind-port 37710  
      Ctrl + A + D
      
    4. Run pool

      screen S pool
      node init.js
      Ctrl + A + D
      
    5. Check the mining pool’s IP via browser, if the content looks like the picture below means the mining pool working correctly.


      If there only texts displayed but did not have actual data, the mining pool may not working normally.