Nodix White Paper

 

General concept....................................................................................................................................................................................................................................................

Running and configuration...................................................................................................................................................................................................................................

Nodix coin script code ...................................................................................................................................................................................................................................

4

Example of bootstrapping the node based on script file................................................................................................................................................................................

6

Node services.................................................................................................................................................................................................................................................

7

Logging and output........................................................................................................................................................................................................................................

9

HTML5 block explorer................................................................................................................................................................................................................................

10

HTML – javascript wallet ...........................................................................................................................................................................................................................

12

Node architecture..................................................................................................................................................................................................................................................

LIBCON.......................................................................................................................................................................................................................................................

13

LIBBASE.....................................................................................................................................................................................................................................................

13

PROTOCOL.................................................................................................................................................................................................................................................

14

BLOCK........................................................................................................................................................................................................................................................

14

SIGNATURE...............................................................................................................................................................................................................................................

14

NODE...........................................................................................................................................................................................................................................................

14

WALLET.....................................................................................................................................................................................................................................................

14

RPC WALLET.............................................................................................................................................................................................................................................

14

BLOCK EXPLORER...................................................................................................................................................................................................................................

14

Staking kernel...............................................................................................................................................................................................................................................

14

COIN............................................................................................................................................................................................................................................................

14

Example of application initialization...........................................................................................................................................................................................................

15

Distributed application framework.......................................................................................................................................................................................................................

Application root...........................................................................................................................................................................................................................................

16

Application definition..................................................................................................................................................................................................................................

17

Application types.........................................................................................................................................................................................................................................

17

Application objects.......................................................................................................................................................................................................................................

18

Application files...........................................................................................................................................................................................................................................

20

Application layouts......................................................................................................................................................................................................................................

21

Application scripts and modules..................................................................................................................................................................................................................

22

Script code for processing of P2P protocol messages..........................................................................................................................................................................................

Application main loop..................................................................................................................................................................................................................................

25

Processing of node messages.......................................................................................................................................................................................................................

26

Code sample of RPC server..................................................................................................................................................................................................................................

liststaking.....................................................................................................................................................................................................................................................

27

getstaketx......................................................................................................................................................................................................................................................

27

getpubaddrs..................................................................................................................................................................................................................................................

29

Code sample of javascript staking in the browser................................................................................................................................................................................................

rpc_call.........................................................................................................................................................................................................................................................

30

staking_loop.................................................................................................................................................................................................................................................

30

list_staking...................................................................................................................................................................................................................................................

30

get_addrs......................................................................................................................................................................................................................................................

30

check_all_staking.........................................................................................................................................................................................................................................

31

1General concept

Nodix is a modular blockchain engine, including distributed application server, which can be used to design customized blockchains, and build easily HTML5/js applications , based on a powerfull and portable C framework, to manipulate hierarchy of dynamic object with lockless multi thread access for maximum parallelism.

The design is very simple, programmed in C, it uses a system of portable binary module which can be created out of .dll or .so files, and used as base building block for distributed application using either C, HTML5/js, or the integrated script engine.

Bitcore and most blockchain client use a monolithic architecture, and alternative blockchains are created by forking the original bitcoin source code tree, changing some hard - coded values and recompiling the core to make the new coin which often contain the masternode server, the blockchain client, and the wallet in a single application executable, with the hard-coded values specific for the coin compiled in, which make it hard to use in a wider application framework.

Instead of monolithic design, each functionalities are encapsulated in different modules, which use enhanced json objects as configuration parameters, which allow flexible node definitions. Modules can be used as application modules used by scripts and other modules, or bound to http service using CGI or JSON/RPC protocol to be used by external application such as javascript.

The problem with monolithic design is that all applications based on the blockchain end up being run on centralized server, who run closed code on a web server on top of the blockchain, with full control of private key, which make them vulnerable to hacks, and not being decentralized or trustless. Most blockchain service are run in such kind of configuration.

With Nodix distributed framework, all the code and data for applications can be hosted and executed on nodes, and the interface provide the API to do full transaction signing and cryptography inside of the browser, which allow to open the RPC interface to the world without compromising private key.

The private keys are encrypted and decrypted inside of the browser, and the node never have to manipulate private key directly.

All together, the portable binary module, script engine and in browser cryptography allow for secure decentralization of applications with a dynamic HTML5 interface, and performant lockless parallel access to application objects from javascript or any language supporting asynchronous JSON/RPC request.

2Running and configuration

As all the functionalities are designed with modularity in mind, it's very easy to adapt the node to specific blockchains, or to add new functionalities into custom blockchain by recompiling only the module containing the specific algorithm, or adding new plugin to the node via module RPC interface binding or script. Binary modules can used on any operating system with intel cpu as long as the libcon library is compiled for this host.

The design rely on a framework of dynamic data tree, which use an internal memory allocator using lockless reference counting mechanism rather than standard C allocation, which allow for easy sharing of data pointer and object hierarchy between different modules without pointer ownership, and to transmit complex data to javascript application or other nodes over the network via the RPC API exposed by the modules.

It allow flexible sharing of object between modules and threads, with the memory being managed automatically by the framework, with acquiring and releasing of objects references done manually in C.

The powerful system of dynamic data tree allow to represent a hierarchy of dynamically typed object/key nodes, used in native script engine to generate HTML5 web pages or json data for HTML5/js application.

The scripting engine is used to define the blockchain node protocol and coin specifics, as well as defining the modules API exposed through node services , and configuring the web server.

Blockchain configuration.

let NODE_GFX_OBJECT configuration = `

{

"name":"nodix", "seed_node" :

{

"host":"nodix.com",

"port" : 16714

},

"magic":0xD9BEFECA, "version":60018,

(NODE_MODULE_DEF) "sign_mod":{"file":"modz/ecdsa.tpo"}, "pubKeyVersion":0x19,

"staking":

{

"targetspacing":64, "maxtargetspacing" : 640, "targettimespan":960, "limit":0x1B00FFFF, "minStakeDepth" : 2, "reward" : 150000000,

(NODE_MODULE_DEF) "pos_kernel" : {"file":"modz/stake_pos3.tpo"}

}, "mining":

{

"targetspacing":64, "maxtargetspacing" : 640, "targettimespan":960, "limit":0x1E0FFFFF, "reward":10000000000000, "last_pow_block":200, "paytxfee":10000

},

 

"genesis":

 

{

 

"version"

:1,

"time"

:1466419085,

"bits"

:0x1e0fffff,

"nonce"

:579883,

"InitialStakeModifier":0, "InitialStakeModifier2":0

}

}`

2.1Nodix coin script code

Node definition.

let NODE_BITCORE_NODE SelfNode = `

{

"user_agent" : "Nodix",

"paytxfee" : 0.01,

"block_height" : 0,

(NODE_GFX_INT)"version" : 0,

(NODE_GFX_INT)"current_pos_diff" : 0,

(NODE_GFX_INT)"current_pow_diff" : 0,

(NODE_BITCORE_BLK_HDR) "last_block" : {},

(NODE_BITCORE_BLK_HDR) "lastPOSBlk" : {},

(NODE_BITCORE_BLK_HDR) "lastPOWBlk" : {}, (NODE_BITCORE_ADDR)"p2p_addr" :

{

"services": 0,

(NODE_NET_IPV)"addr" : "127.0.0.1",

(NODE_GFX_SHORT)"port" : 16819

},

(NODE_SERVICE)"http_service":

{

"port"

: 16820,

"docroot"

: "web",

"name"

: "nodix webservice",

"indexpage" : "/nodix.site",

"mimes" : {

"js":"text/javascript",

 

"css" : "text/css",

 

"png" : "image/png",

 

"svg" : "image/svg+xml",

 

"html": "text/html" },

"defaultmime" : "text/plain",

"maxpost"

: 1024,

"modules"

:

[

{"base" : "/jsonrpc", "type" : "rpc", (NODE_MODULE_DEF) "rpc_wallet"

: {"file":"modz/rpc_wallet.tpo"}},

 

]

{"base" : "/api/"

, "type" : "cgi", (NODE_MODULE_DEF) "block_explorer" : {"file":"modz/block_explorer.tpo"}}

 

 

 

 

},

 

 

 

 

(NODE_BITCORE_NODE_LIST) "peer_nodes" : [],

 

(NODE_BITCORE_WALLET_ADDR_LIST) "addr scan list" : null,

 

(NODE_BITCORE_MSG_LIST) "send queue" : [],

 

(NODE_BITCORE_MSG_LIST) "emitted_queue" : [],

 

(NODE_BITCORE_TX_LIST) "tx mem pool" : [],

 

(NODE_BITCORE_BLK_HDR_LIST) "submitted blocks" : []

 

}`

 

 

 

 

Import modules

 

 

 

 

let NODE_MODULE_DEF

vec = `{"order":0, "file" : "modz/vec3.tpo"}`

 

let NODE_MODULE_DEF

protocol_adx = `{"order":1, "file" : "modz/protocol_adx.tpo"}`

 

let NODE_MODULE_DEF

block_adx = `{"order":2, "file" : "modz/block_adx.tpo"}`

 

let NODE_MODULE_DEF

wallet= `{"order":3, "file" : "modz/wallet.tpo"}`

 

let NODE_MODULE_DEF

node_adx = `{"order":4, "file" : "modz/node_adx.tpo"}`

 

let NODE_MODULE_DEF

nodix = `{"order":5, "file" : "modz/nodix.tpo"}`

 

Global variables

 

 

 

 

let NODE_BITCORE_BLK_HDR

genesis_blk

= `{}`

 

let NODE_GFX_INT

 

ping_nonce

= 1

 

let NODE_GFX_BINT

 

block_reward = 0

 

let NODE_GFX_BINT

 

lost_reward = 0

 

let NODE_GFX_BINT

 

cur_len = 0

 

 

Node initialization code

proc init_node = `

 

protocol_adx.init_protocol

(configuration)

block_adx.init_blocks

(configuration)

node_adx.node_init_self

(SelfNode)

loadmod

(configuration.staking.pos_kernel)

configuration.staking.pos_kernel.init_pos

(configuration.staking)

 

node_adx.node_init_service

(SelfNode.http_service,

configuration.staking.pos_kernel)

set SelfNode.version = configuration.version;

set SelfNode.block_reward = configuration.mining.reward;

node_adx.node_load_block_indexes

 

()

block_adx.make_genesis_block

(configuration.genesis, genesis_blk)

if (SelfNode.block_height = 0)

 

 

node_adx.node_set_last_block

(genesis_blk)

nodix.compute_pow_diff

 

(genesis_blk, SelfNode.current_pow_diff)

configuration.staking.pos_kernel.store_blk_staking (genesis_blk)

endif

if (SelfNode.block_height > 1)

node_adx.node_load_last_blks()

 

 

block_adx.get_pow_reward(SelfNode.lastPOWBlk.height, block_reward)

 

 

set SelfNode.pow_reward = block_reward;

 

 

configuration.staking.pos_kernel.load_last_pos_blk(SelfNode.lastPOSBlk)

:

set SelfNode.lastPOSBlk = SelfNode.last_block;

 

 

configuration.staking.pos_kernel.find_last_pos_block(SelfNode.lastPOSBlk)

node_adx.node_store_last_pos_hash

(SelfNode.lastPOSBlk)

endor

configuration.staking.pos_kernel.compute_last_pos_diff (SelfNode.lastPOSBlk, SelfNode.current_pos_diff) : set SelfNode.current_pos_diff = configuration.staking.limit;

endor

configuration.staking.pos_kernel.stake_get_reward (SelfNode.lastPOSBlk.height, block_reward) ? set SelfNode.pos_reward = block_reward;

endor

endif

sethandler SelfNode.emitted_queue{ "cmd=verack" } = on_verack; sethandler SelfNode.emitted_queue{ "cmd=version" } = on_version; sethandler SelfNode.emitted_queue{ "cmd=ping" } = on_ping; sethandler SelfNode.emitted_queue{ "cmd=pong" } = on_pong; sethandler SelfNode.emitted_queue{ "cmd=inv" } = on_inv; sethandler SelfNode.emitted_queue{ "cmd=addr" } = on_addr; sethandler SelfNode.emitted_queue{ "cmd=block" } = on_block;

node_adx.new_peer_node(configuration.seed_node)

node_adx.queue_version_message(SelfNode.peer_nodes[0]) node_adx.queue_getaddr_message(SelfNode.peer_nodes[0])

`

2.2Example of bootstrapping the node based on script file

int main(int argc, const char **argv)

{

 

 

app_func_ptr

 

app_init, app_start, app_loop, app_stop;

struct string

 

node_name = { PTR_NULL };

mem_zone_ref

 

params = { PTR_NULL }, script_vars = { PTR_NULL }, init_node_proc = { PTR_NULL };

tpo_mod_file

 

*nodix_mod;

int done = 0,n;

 

 

init_mem_system

 

();

init_default_mem_area

(24 * 1024 * 1024);

set_exe_path

 

();

network_init

 

();

load_module

("modz/libbase.tpo", "libbase", &libbase_mod);

load_script

 

= get_tpo_mod_exp_addr_name(&libbase_mod, "load_script", 0);

resolve_script_var

 

= get_tpo_mod_exp_addr_name(&libbase_mod, "resolve_script_var", 0);

get_script_var_value_str

= get_tpo_mod_exp_addr_name(&libbase_mod, "get_script_var_value_str", 0);

get_script_var_value_ptr

= get_tpo_mod_exp_addr_name(&libbase_mod, "get_script_var_value_ptr", 0);

execute_script_proc

 

= get_tpo_mod_exp_addr_name(&libbase_mod, "execute_script_proc", 0);

tree_manager_init

 

= get_tpo_mod_exp_addr_name(&libbase_mod, "tree_manager_init", 0);

tree_manager_init

(16 * 1024 * 1024);

load_script

("nodix.node", &script_vars,3);

if (!get_script_var_value_str(&script_vars, "configuration.name", &node_name, 0)) make_string(&node_name, "nodix");

if (!set_home_path(node_name.str))

{

console_print("could not set home dir 'nodix' \n"); return 0;

}

get_script_var_value_ptr (&script_vars, "nodix.mod_ptr" , &nodix_mod);

app_init = (app_func_ptr)get_tpo_mod_exp_addr_name(nodix_mod, "app_init", 0); app_start = (app_func_ptr)get_tpo_mod_exp_addr_name(nodix_mod, "app_start", 0); app_loop = (app_func_ptr)get_tpo_mod_exp_addr_name(nodix_mod, "app_loop", 0); app_stop = (app_func_ptr)get_tpo_mod_exp_addr_name(nodix_mod, "app_stop", 0);

if (!app_init(&script_vars))

{

console_print("could not initialize app "); console_print(nodix_mod->name); console_print("\n");

return 0;

}

 

 

resolve_script_var

(&script_vars,PTR_NULL, "init_node"

, 0xFFFFFFFF ,&init_node_proc);

execute_script_proc

(&script_vars, &init_node_proc);

 

if (daemonize(node_name.str) <= 0)

{

console_print("daemonize failed \n"); return 0;

}

if (!app_start(¶ms))

{

console_print("could not start app "); console_print(nodix_mod->name); console_print("\n");

return 0;

}

while (isRunning())

{

app_loop(PTR_NULL);

}

app_stop(PTR_NULL);

}

2.3 Node services

Additionally to basic block chain functions, nodes can expose services via http protocol.

Those services can be defined in 3 manners :

From binary modules using classic cgi interface with parameters passed via the HTTP URL

From binary modules using JSON/RPC over HTTP request.

Either full web pages generated by the nodix script engine.

Sample page script from nodix.site

let NODE_JSON_ARRAY stylesheets = `[ "//fonts.googleapis.com/css?family=Open+Sans:400,300,600&subset=cyrillic,latin", "/assets/plugins/bootstrap/css/bootstrap.min.css",

"/assets/css/style.css", "/assets/css/headers/header-default.css", "/assets/css/blocks.css", "/assets/css/footers/footer-v7.css", "/assets/plugins/animate.css", "/assets/plugins/line-icons/line-icons.css", "/assets/plugins/font-awesome/css/font-awesome.min.css", "/assets/plugins/brand-buttons/brand-buttons.css", "/assets/css/theme-skins/dark.css", "/assets/css/custom.css", "/assets/plugins/sky-forms-pro/skyforms/css/sky-forms.css", "/assets/plugins/sky-forms-pro/skyforms/custom/custom-sky-forms.css"

]`

let NODE_JSON_ARRAY scripts = `[ "/assets/plugins/jquery/jquery.min.js", "/assets/plugins/jquery/jquery-migrate.min.js", "/assets/plugins/bootstrap/js/bootstrap.min.js", "/assets/plugins/back-to-top.js", "/assets/plugins/smoothScroll.js", "/assets/plugins/sky-forms-pro/skyforms/js/jquery-ui.min.js", "/assets/plugins/sky-forms-pro/skyforms/js/jquery.validate.min.js", "/assets/plugins/sky-forms-pro/skyforms/js/jquery.maskedinput.min.js", "/assets/plugins/scrollbar/js/jquery.mCustomScrollbar.concat.min.js", "/assets/js/custom.js",

"/assets/js/app.js"

]`

let NODE_JSON_ARRAY metas = `[ {"viewport":"width=device-width, initial-scale=1.0"}, {"description":""},

{"author":""}

]`

let NODE_MODULE_DEF node_adx = `{"file" : "modz/node_adx.tpo"}` let NODE_JSON_ARRAY node_modules = `[]`

page services = `

html_head "NODIX SERVICE INFO ( SERVICES )" html_block "templates/menu.html" html_block "templates/services.html" html_scripts

html_var SelfNode.http_service;

html_js $(document).ready(function ()

{

App.init();

App.initScrollBar();

site_base_url = '/nodix.site'; api_base_url ='';

lang = 'en';

$('#serv_port').html(http_service.port); $('#serv_name').html(http_service.name); $('#serv_root').html(http_service.docroot); $('#index').html(http_service.indexpage); $('#defaultmime').html(http_service.defaultmime);

make_mime_table('mimes',http_service.mimes);

if(http_service.http_status==1) $('#status').html ('running');

else

$('#status').html ('stopped');

mods = http_service.modules;

make_modules_html ('service_modz_div',http_service.modules);

make_scripts_html ('service_scriptz_div',http_service.nodescripts);

});

end_js

html_block "templates/footer.html"

`

Pages from site scripts can be accessed via http://node-ip:service-port/script-file.site/page-name

For example, the page implemented as the 'services' method in the script 'nodix.site' can be accessed at the address http://node-ip:service-port/nodix.site/services

Functions exported from binary modules can be accessed as an RPC method on the service or bound to HTTP URL path with CGI API using the node configuration file.

(NODE_SERVICE)"http_service":

 

 

{

 

 

 

"port"

: 16820,

#port used to connect the service

"docroot"

: "web",

#root folder for web files

"name"

: "nodix webservice",

#name of

the service

"indexpage" : "/nodix.site",

#default

index page

"mimes" : {

"js":"text/javascript",

#list of

mime-type / file extensions

 

"css" : "text/css",

 

 

 

"png" : "image/png",

 

 

 

"svg" : "image/svg+xml",

 

 

 

"html": "text/html" },

 

 

"defaultmime" : "text/plain",

#default

mime type

"maxpost"

: 1024,

#max size of HTTP POST data

"modules"

:

#list of

modules exposed through the http interface

[

 

 

 

 

{"base" : "/jsonrpc", "type"

: "rpc", (NODE_MODULE_DEF)

"rpc_wallet"

: {"file":"modz/rpc_wallet.tpo"}},

{"base" : "/api/"

, "type"

: "cgi", (NODE_MODULE_DEF)

"block_explorer"

: {"file":"modz/block_explorer.tpo"}}

]

 

 

 

 

}

This line bind functions exported from the binary module 'modz/rpc_wallet.tpo' as RPC/JSON method to the URL path '/jsonrpc'.

{"base" : "/jsonrpc", "type" : "rpc", (NODE_MODULE_DEF) "rpc_wallet"

: {"file":"modz/rpc_wallet.tpo"}},

which can be called via http://node-ip:port/jsonrpc

This line bind function exported from binary module 'modz/block_explorer.tpo' to the base URL '/api/'

{"base" : "/api/" , "type" : "cgi", (NODE_MODULE_DEF) "block_explorer" : {"file":"modz/block_explorer.tpo"}}

which can be called via http://node-ip:port/api/function_name

Function executed via JSON/RPC or CGI interface are always executed in a thread parrallelized from the main node thread and from each other.

The lockless architecture allow to manipulate object hierarchy in a thread safe manner transparently.

2.4Logging and output

app start

[59346414] new message version, 3273490296 playload : 100 bytes from 'nodix.eu':16714

[59346414] node 82.165.128.213:16714 /Satoshi:1.2.2/ version 60018 network last block: 110182, me 88.190.203.85:58158

[59346415] new message verack, 3806393949 playload : 0 bytes from 'nodix.eu':16714

[59346415] new message ping, 1847727446 playload : 8 bytes from 'nodix.eu':16714

[59346415] new message pong, 1799312136 playload : 8 bytes from 'nodix.eu':16714

[59346415] block locator:

[59346415] new message inv, 3312959199 playload : 18003 bytes from 'nodix.eu':16714

[59346416] new message block, 1807715441 playload : 174 bytes from 'nodix.eu':16714

[59346416] new message block, 902439508 playload : 174 bytes from 'nodix.eu':16714

[59346416] ----------------

NEW POW BLOCK 00000FFFFF000000000000000000000000000000000000000000000000000000 00000ED287279BDB4CE0CB9B7E4611143FEB16E5ED4B897EC2B3CF876CFFA260 A611A6783AA6FB83782A454CB11DB2A926E9CCA2678905F8399ED3AF2B6749AF

verify block txs store block store staking new block added

[59346416] new blockchain height : 2

[59346416] new message block, 258200734 playload : 174 bytes from 'nodix.eu':16714

[59346416] ----------------

NEW POW BLOCK 00000FFFFF000000000000000000000000000000000000000000000000000000 00000F8C244B19B589F6E03072EEC8277B223D8B01F3AFD3982997B8A9B36221 B7D330DE9622B3E6805573536B715D3C1ADCC34F008A82DC0C42576D502BD7F9

verify block txs store block store staking new block added

[59346416] new blockchain height : 3

Nodix framework allow dumping of any dynamic object safely without using C/C++ stdio or streams, using it's own formatting of message from dynamic object definition, which allow easy debugging and logging of complex object hierarchy without running into unsafe text stream function of C runtime.

2.5HTML5 block explorer

Blockchain nodes usually does not contain a block explorer, and it's generally another software bundle using its own database and node.js service, with nodix, the block explorer database and api is fully integrated in the node as an application service.

List of blocks by date and search engine / filtering

http://nodix.eu:16820/nodix.site/blocks

http://nodix.eu:16820/api/blocks?BlockDate=2017-06-05

=>

blocks:[,…]

0:{reward: 150000000, stakemodifier2: "E44472EEAF3FD27715F048112D7716EA63308B96A81E2F3A6C82BF46BD141A76",…}

bits:440209823

confirmations:294

difficulty:274722.125

hash:"D86A837ACF95DA6BB9E6CBB0B69E094B30B6005ED72FD1CC6BEF600E810F1546"

hbits:"0000000000003D119F0000000000000000000000000000000000000000000000"

height:110221

isCoinbase:false

merkleroot:"7E8441A68E35753A7073103A8D6D679AAF42BACE179DF89D4EA531833347845D"

nextblockhash:"D3D0BCB3B072F9D40AD85070DD31EC3BC9DEBAB21CCA4AB1879A66B7EFB4873F"

nonce:0

previousblockhash:"49FBB5C45C15B6C53AF5B2F8BAD595F71B379E1BF1FB3FA4BDE9CF97D371070B"

proofhash:"000041F0292E0C63E1ABFA35FCAAFDA211FE7622E51F8F574151B5B3B98E256F"

reward:150000000

size:330

stakemodifier2:"E44472EEAF3FD27715F048112D7716EA63308B96A81E2F3A6C82BF46BD141A76"

time:1496670496

tx:["4004A0841A2E4B8CD437766215A58EF3DCBEFAAEAD4968F4DB765D4B8D1250B5",…] 0:"4004A0841A2E4B8CD437766215A58EF3DCBEFAAEAD4968F4DB765D4B8D1250B5"

1:"4D499776222C39D2951B317AD1FECA1F2E3B0FB5959AD0AFD3842FE292C54D01"

version:7

http://nodix.eu:16820/api/txs?BlockDate=2017-06-05&pageNum=0

=>

txs:[{blockhash: "D86A837ACF95DA6BB9E6CBB0B69E094B30B6005ED72FD1CC6BEF600E810F1546",…},…]

0:{blockhash: "D86A837ACF95DA6BB9E6CBB0B69E094B30B6005ED72FD1CC6BEF600E810F1546",…}

1:{blockhash: "D86A837ACF95DA6BB9E6CBB0B69E094B30B6005ED72FD1CC6BEF600E810F1546",…}

blockhash:"D86A837ACF95DA6BB9E6CBB0B69E094B30B6005ED72FD1CC6BEF600E810F1546"

blockheight:110221

blocktime:1508708742

confirmations:294

isCoinBase:false

size:181

time:1496670496

txid:"4D499776222C39D2951B317AD1FECA1F2E3B0FB5959AD0AFD3842FE292C54D01" vin:[{value: 10066000000, addresses: ["BRcMT11Hfymgf5hViqiRg12zwSyLoSPibG"],…}] 0:{value: 10066000000, addresses: ["BRcMT11Hfymgf5hViqiRg12zwSyLoSPibG"],…} addresses:["BRcMT11Hfymgf5hViqiRg12zwSyLoSPibG"] 0:"BRcMT11Hfymgf5hViqiRg12zwSyLoSPibG"

idx:2

n:0

prevhash:"D82713FE8E0F3C06D0A49F694658439EC933A849A948BEDDE755989258A62270"

sequence:4294967295

value:10066000000

vout:

0:{value: 0, n: 0, isNull: true}

1:{value: 10216000000, n: 1, isNull: false,…}

Transaction by address

http://nodix.eu:16820/api/txs?address=BRcMT11Hfymgf5hViqiRg12zwSyLoSPibG&pageNum=0

numtx:1402 txs:

0:

blockhash:"37531A82E21ADA1B310180851DAD72A09A36C501F9F2BD8C7EC7AC306895AC41"

blockheight:98

blocktime:1508671270

confirmations:110417

isCoinBase:true

size:93

time:1467221980

txid:"796ACDF1ACB361930E64D965FF7275044B87F9703DDE45475CF4CFD818D93DD8"

vin:[{coinbase: "01610103", n: 0, sequence: 4294967295}]

0:{coinbase: "01610103", n: 0, sequence: 4294967295}

coinbase:"01610103"

n:0

sequence:4294967295

vout:[{value: 10000000000000, n: 0, isNull: false,…}]

0:{value: 10000000000000, n: 0, isNull: false,…} addresses:["BRcMT11Hfymgf5hViqiRg12zwSyLoSPibG"] isNull:false

n:0

scriptPubKey:{hex: "76A914E81B99F7184A682459FABF6548C14B2989CFEC6B88AC", type: "paytoscript"}

value:10000000000000

2.6HTML – javascript wallet

The node also include the RPCAPI for an HTML5/js wallet able to generate private key and sign transaction using javascript code, as well as staking in the browser, allowing maximum privacy, as the private key never leave the browser in clear form.

It's decrypted in the browser using user supplied secret, and then these private key are used to sign transaction right inside the browser.

Nodes never have to manipulate or access private key, but still keep track of transaction on public addresses, allowing read-only wallet, and manipulations of private key. Hash signing is made inside of the browser without the node knowing about the private key at all.

3Node architecture

= binaries compiled for each host target = cross platform binary module

LIBCON

 

 

LIBBASE

 

 

Network

 

 

 

 

 

packet

 

 

 

 

 

NODE

P2P messages

PROTOCOL

 

 

 

 

 

 

 

BLOCK

 

 

 

 

HEADER

 

 

 

 

TX

 

 

 

 

TX

 

Event object

Tree of dynamic objects

 

 

 

HTTP

COIN

Block validation

 

STAKING

services

CORE

 

 

 

KERNEL

 

launcher

 

 

BLOCK

 

 

(POW/transactions)

Local storage

 

 

 

 

 

 

RPC

 

CGI

PAGE

MOD

 

MOD

 

SCRIPT

 

JSON/

 

HTTP/

 

HTML5

RPC

 

JSON

 

App

Javascript browser

Fetching data

Decryption of private key

Generation of html from json

hash signing

3.1LIBCON ( has to be compiled for the host)

Memory allocation of reference counted pointer and basic memory manipulation.

Strings and basic text manipulation, utf8.

File system access and I/O.

Socket and network.

XML Parser (expat) used by uPnp.

Zlib for compression/decompression.

Binary module loader.

Base C runtime.

3.2LIBBASE (distributed as system agnostic binary module)

Dynamic object tree based on references pointer.

HTTP protocol.

JSON parser.

Nodix script parser.

UPNP.

hashes (SHA256,MD5,RIP160)

3.3PROTOCOL (distributed as source)

Parsing of bitcore protocol message and deserialization as dynamic object tree.

Creation of new messages using the bitcore protocol based on dynamic objects.

3.4BLOCK (distributed as source)

Function to check block's proof of work.

Functions to manipulate and verify transactions.

Function to store block and transaction data

Function to manipulate applications items.

3.5SIGNATURE (distributed as source)

Functions to generate key pairs

Functions to extract public key from private key

Function to verify data signature

3.6NODE(distributed as system agnostic binary module)

Reception and emission of P2P network packet.

Management of blockchain state.

Loading of RPC and CGI module.

Handling of HTTP json/ajax/rpc request.

Handling of web page generation requests.

3.7WALLET(distributed as system agnostic binary module)

Storing of public and crypted private key.

Listing and management of transaction history.

Generation of staking information.

3.8RPC WALLET(distributed as source)

Function to retrieve information on addresses compatible with bitcore RPC API, without the transaction signing related methods which are decentralized to client HTML5 WebApp.

3.9BLOCK EXPLORER(distributed as source)

Block explorer web api functions to output json formatted data (called from javascript in the block explorer page).

3.10Staking kernel (distributed as source)

Validation of proof of stake block and staking reward.

Storing of pos specific data on the local system.

Computing proof of stake difficulty re-targeting.

Generation of new proof of stake block template for staking.

3.11COIN (distributed as source)

Loading of configuration file.

Initialization of the proof of stake kernel module.

Initialization of the node module.

Global coin logic and network message handling

3.12Example of application initialization

OS_API_C_FUNC(int) app_init(mem_zone_ref_ptr params)

{

mem_zone_ref

log = { PTR_NULL };

unsigned char *data;

size_t

data_len;

int

ret;

pos_kernel = PTR_NULL; self_node.zone = PTR_NULL; node_config.zone = PTR_NULL; seed_node.zone = PTR_NULL; pos_kernel_def.zone = PTR_NULL;

memset_c(null_hash, 0, 32);

create_dir("txs");

if (stat_file("txs") != 0)

{

log_message("unable to create tx dir \n", PTR_NULL); return 0;

}

create_dir("blks");

if (stat_file("blks") != 0)

{

log_message("unable to create blks dir \n", PTR_NULL); return 0;

}

create_dir("adrs");

if (stat_file("adrs") != 0)

{

log_message("unable to create adrs dir \n", PTR_NULL); return 0;

}

if (params != PTR_NULL)

{

mem_zone_ref stake_mod_def = { PTR_NULL };

ret=resolve_script_var

(params, PTR_NULL,"configuration"

if (ret)ret = resolve_script_var

(params, PTR_NULL,"SelfNode"

if (ret)ret = resolve_script_var

(params, PTR_NULL,"configuration.staking.pos_kernel"

if (ret)ret = resolve_script_var

(params, PTR_NULL,"configuration.seed_node"

if(ret)node_set_script

(params);

}

 

if (!ret)

 

{

 

release_zone_ref(&seed_node);

 

release_zone_ref(&node_config);

 

release_zone_ref(&self_node);

 

}

 

return ret;

 

}

,NODE_GFX_OBJECT, &node_config);

,NODE_BITCORE_NODE, &self_node);

,NODE_MODULE_DEF, &pos_kernel_def);

,0xFFFFFFFF, &seed_node);

4Distributed application framework

Nodix blockchain allow to represent full application on the blockchain, including object type definitions, objects data, files, layout and code, as a full MVC ( Movel View Controller) stack.

First an application root has to be included on the blockchain, then application definitions can be included as child of this root application, and application elements added as child of the application definition.

The applications page in the html wallet can be used to create application root and new application entries.

Transactions are first generated by the node from input parameters in the html UI, then send back to the UI with their signing hash. The javascript application then sign the transaction using the private key decrypted in the browser based on user supplied secret before being sent to the node's memory pool and propagated to the network.

4.1 Application root

The application root is the entry point for applications. Its first input contain null txid and idx, with the script containing a single text variable set to “approot”.

Its first output contain the application root address, and the amount of the utxo set the fee to pay to the app root address in order to add a new application.

4.2 Application definition

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Application definition

 

 

Application root

 

 

 

 

 

 

 

 

 

 

 

Txid:null;idx:0xFF

 

 

 

 

Approot txin

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Root address,app fees

 

 

 

 

App addr; Types def

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

App addr; Objects

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

App addr; Files

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

App addr; Layouts

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

App addr; Modules

 

 

 

 

 

 

 

 

 

Application definitions are the entry point for applications. Their input link to the application root, and each output is used to add new entry in the application, containing the application address used to sign new entries to the application.

Additionally to the input linking to the application root and applications outputs, this transaction need to contain regular input and outputs that send the app fee to the address set in the application root.

Once the application is created, it can be accessed via http://node-ip:port/application/app_name

4.3 Application types

Application types can be created on the application page. The address used to create the application need to be selected to add a new type.

 

Application definition

 

 

 

 

 

 

 

 

 

 

Type definition

 

 

 

 

 

 

 

 

 

 

Approot txin

 

 

 

 

 

 

 

 

 

 

 

 

Link to application type

 

 

 

 

 

 

 

 

Include app signature

 

 

 

 

 

 

 

 

 

 

 

 

 

 

App addr; Types def

 

 

 

 

 

 

 

 

 

 

Type name and ID

 

 

 

 

 

 

 

 

 

 

 

App addr; Objects

 

 

 

 

 

 

 

 

 

 

 

 

 

Key #1 type and name

 

 

 

 

 

App addr; Files

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Key #2 type and name

 

 

App addr; Layouts

 

 

 

 

 

 

 

 

 

App addr; Modules

 

 

 

Key #2 type and name

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Key's type can be built in base types, application type, references to other objects or files, or a list of private or public childs that can be added to the object.

4.4 Application objects

Application definition

Approot txin

App addr; Types def

App addr; Objects

App addr; Files

App addr; Layouts

App addr; Modules

Object definition

Link to application object

Object signature

Object Type Id

Object Address Object serialized data

Once a type has been created, new objects can be created by filling the fields in the application page. Objects are signed with user supplied address.

Objects that have already been created for this application are listed in green below the type definition, and their data can be seen by clicking on the hash that correspond to the transaction that define the object.

New children can be added to existing object that has a child key entry. If the child key is not public, the address used to create the object need to be selected in order to add a child to the object.

Object definition

Link to application object

Object signature

Object Type Id

Object Address Object serialized data

Object child

Link to object

Signature for non public key

Parent key

Child object tx hash

Unlike SQL database, the object hierarchy allow to access easily all children added to an object key without having to parse all objects of that type, and load a whole object hierarchy with a single command.

4.5 Application files

New files can be uploaded using the application page. First select the file using the file box, it will be then be uploaded as a temporary file, then select the address used to sign the file and create the transaction to store the file permanently on the node.

Only meta information about the file are stored on the blockchain, and a special protocol message combined with a getdata message are used to propagate the file based on this definition.

 

Application definition

 

 

 

File definition

 

 

 

 

 

 

 

 

 

Approot txin

 

 

 

 

 

 

 

 

 

 

Link to application file

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

App addr; Types def

 

 

 

 

 

 

 

 

 

Filename

 

 

 

 

 

 

 

 

 

App addr; Objects

 

 

 

 

Mime type

 

 

App addr; Files

 

 

 

Size

 

 

 

 

 

 

 

 

 

 

File hash

 

 

 

 

 

App addr; Layouts

 

 

 

 

PubKey

 

 

 

 

 

 

 

Signature

 

 

App addr; Modules