From 3a170fee890caa00c2ef7f30858311786dcf4ca6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Jan 2017 11:14:10 +0200 Subject: [PATCH 1/8] KV --- iguana/coins/basilisk/kv | 1 + iguana/coins/kv_7776 | 1 + iguana/iguana_notary.c | 2 +- iguana/m_notary | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) create mode 100755 iguana/coins/basilisk/kv create mode 100755 iguana/coins/kv_7776 diff --git a/iguana/coins/basilisk/kv b/iguana/coins/basilisk/kv new file mode 100755 index 000000000..6e060642b --- /dev/null +++ b/iguana/coins/basilisk/kv @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"KV.conf\",\"path\":\"${HOME#"/"}/.komodo/KV\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"KV\",\"name\":\"KV\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"f434f1c5\",\"p2p\":8298,\"rpc\":8299,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" diff --git a/iguana/coins/kv_7776 b/iguana/coins/kv_7776 new file mode 100755 index 000000000..8e9098912 --- /dev/null +++ b/iguana/coins/kv_7776 @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"KV.conf\",\"path\":\"${HOME#"/"}/.komodo/KV\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"KV\",\"name\":\"KV\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"f434f1c5\",\"p2p\":8298,\"rpc\":8299,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index f1772b2d3..f9d5b261c 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -436,7 +436,7 @@ STRING_ARG(iguana,addnotary,ipaddr) char NOTARY_CURRENCIES[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", - "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW", "MVP", "WIRELESS" }; + "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW", "MVP", "WIRELESS", "KV" }; ZERO_ARGS(dpow,notarychains) { diff --git a/iguana/m_notary b/iguana/m_notary index 89719cb4b..a064cad7d 100755 --- a/iguana/m_notary +++ b/iguana/m_notary @@ -36,6 +36,7 @@ coins/pangea_7776 coins/mgw_7776 coins/mvp_7776 coins/wireless_7776 +coins/kv_7776 curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"passthru\",\"method\":\"paxfiats\",\"timeout\":900000}" #curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"$myip\"}" From f2860ccd146a75841844415be325b2799a1ed40e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 20 Jan 2017 15:35:48 +0200 Subject: [PATCH 2/8] print fund notaries --- iguana/iguana_notary.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index f9d5b261c..c4f984539 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -495,7 +495,7 @@ STRING_AND_INT(dpow,fundnotaries,symbol,numblocks) printf("ERROR with (%s)\n",cmd); else { - printf("(%d %f) ",j,val); + printf("%s\n",cmd); sum += val; } } From 3b8a1ece30d696400662f2630f1e459c77a73054 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Jan 2017 12:09:03 +0200 Subject: [PATCH 3/8] dexkvsearch and dexkvupdate --- iguana/dPoW.h | 9 +++++-- iguana/dpow/dpow_network.c | 44 +++++++++++++++++++++++++++++++++++ iguana/dpow/dpow_rpc.c | 35 ++++++++++++++++++++++++++++ iguana/iguana_notary.c | 10 ++++++++ includes/iguana_apideclares.h | 2 ++ 5 files changed, 98 insertions(+), 2 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 09adc2903..fbb9f006d 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -22,7 +22,7 @@ #define DPOW_MINSIGS 17 //#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1) #define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries) -#define DPOW_VERSION 0x0780 +#define DPOW_VERSION 0x0781 #define DPOW_UTXOSIZE 10000 #define DPOW_MINOUTPUT 6000 #define DPOW_DURATION 600 @@ -45,7 +45,7 @@ #define DPOW_MAXRELAYS 64 #define DPOW_MAXSIGLEN 128 -#define DEX_VERSION 0x0104 +#define DEX_VERSION 0x0105 #define DPOW_SOCK 7775 #define DEX_SOCK 7774 #define PUB_SOCK 7773 @@ -164,6 +164,8 @@ char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip); char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin); +cJSON *dpow_kvupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *key,char *value,int32_t flags); +cJSON *dpow_kvsearch(struct supernet_info *myinfo,struct iguana_info *coin,char *key); void init_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin); char *_dex_getinfo(struct supernet_info *myinfo,char *symbol); @@ -180,6 +182,9 @@ char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *coin char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol); int32_t _dex_getheight(struct supernet_info *myinfo,char *symbol); char *_dex_getnotaries(struct supernet_info *myinfo,char *symbol); +char *_dex_kvupdate(struct supernet_info *myinfo,char *symbol,char *key,char *value,int32_t flags); +char *_dex_kvsearch(struct supernet_info *myinfo,char *symbol,char *key); + int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height); cJSON *dpow_checkaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 5a762be78..5d49799c6 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -498,6 +498,26 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d retstr = jprint(retjson,1); } } + else if ( dexreq.func == 'k' ) + { + if ( strcmp(coin->symbol,"BTC") == 0 || strcmp(coin->symbol,"ZEC") == 0 || coin->chain->zcash == 0 ) + retstr = clonestr("{\"error\":\"only komodod chains support KV\"}"); + else if ( (retjson= dpow_kvsearch(myinfo,coin,(char *)&dexp->packet[datalen])) != 0 ) + { + dpow_randipbits(myinfo,coin,retjson); + retstr = jprint(retjson,1); + } + } + else if ( dexreq.func == 'K' ) + { + if ( strcmp(coin->symbol,"BTC") == 0 || strcmp(coin->symbol,"ZEC") == 0 || coin->chain->zcash == 0 ) + retstr = clonestr("{\"error\":\"only komodod chains support KV\"}"); + else if ( (retjson= dpow_kvupdate(myinfo,coin,(char *)&dexp->packet[datalen],(char *)&dexp->packet[datalen+dexreq.shortarg],dexreq.intarg)) != 0 ) + { + dpow_randipbits(myinfo,coin,retjson); + retstr = jprint(retjson,1); + } + } else if ( dexreq.func == 'U' ) { if ( (retjson= dpow_listunspent(myinfo,coin,(char *)&dexp->packet[datalen])) != 0 ) @@ -741,6 +761,30 @@ char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32 return(_dex_sendrequest(myinfo,&dexreq,3,"value")); } +char *_dex_kvupdate(struct supernet_info *myinfo,char *symbol,char *key,char *value,int32_t flags) +{ + struct dex_request dexreq; char keyvalue[IGUANA_MAXSCRIPTSIZE]; int32_t keylen,valuesize; + memset(&dexreq,0,sizeof(dexreq)); + safecopy(dexreq.name,symbol,sizeof(dexreq.name)); + dexreq.func = 'K'; + dexreq.intarg = flags; + keylen = (int32_t)strlen(key); + memcpy(keyvalue,key,keylen+1); + valuesize = (int32_t)strlen(value); + dexreq.shortarg = keylen+1; + memcpy(&keyvalue[dexreq.shortarg],value,valuesize+1); + return(_dex_sendrequeststr(myinfo,&dexreq,keyvalue,1,"")); +} + +char *_dex_kvsearch(struct supernet_info *myinfo,char *symbol,char *key) +{ + struct dex_request dexreq; + memset(&dexreq,0,sizeof(dexreq)); + safecopy(dexreq.name,symbol,sizeof(dexreq.name)); + dexreq.func = 'k'; + return(_dex_sendrequeststr(myinfo,&dexreq,key,1,"")); +} + char *_dex_getinfo(struct supernet_info *myinfo,char *symbol) { struct dex_request dexreq; diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 525d38441..953c2d388 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -410,6 +410,41 @@ char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *c } } +cJSON *dpow_kvupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *key,char *value,int32_t flags) +{ + char params[IGUANA_MAXSCRIPTSIZE+256],*retstr; cJSON *retjson; + if ( coin->FULLNODE < 0 ) + { + sprintf(params,"[\"%s\", \"%s\", \"%d\"]",key,value,flags); + retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"kvupdate",params); + if ( (retjson= cJSON_Parse(retstr)) == 0 ) + { + free(retstr); + return(cJSON_Parse("{\"error\":\"couldnt parse kvupdate return\"}")); + } + free(retstr); + return(retjson); + } else return(cJSON_Parse("{\"error\":\"only native komodod supports KV\"}")); +} + +cJSON *dpow_kvsearch(struct supernet_info *myinfo,struct iguana_info *coin,char *key) +{ + char params[IGUANA_MAXSCRIPTSIZE+256],*retstr; cJSON *retjson; + if ( coin->FULLNODE < 0 ) + { + sprintf(params,"[\"%s\"]",key); + retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"kvsearch",params); + if ( (retjson= cJSON_Parse(retstr)) == 0 ) + { + free(retstr); + return(cJSON_Parse("{\"error\":\"couldnt parse kvupdate return\"}")); + } + free(retstr); + return(retjson); + } else return(cJSON_Parse("{\"error\":\"only native komodod supports KV\"}")); +} + + char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx) { bits256 txid; cJSON *json,*array; char *paramstr,*retstr; diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index c4f984539..cdf4fd669 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -669,6 +669,16 @@ STRING_ARG(dex,getnotaries,symbol) return(_dex_getnotaries(myinfo,symbol)); } +TWO_STRINGS(dex,kvsearch,symbol,key) +{ + return(_dex_kvsearch(myinfo,symbol,key)); +} + +THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb) +{ + return(_dex_kvupdate(myinfo,symbol,key,value,flags)); +} + #include "../includes/iguana_apiundefs.h" diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 1449b0ff8..cd70955cb 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -39,6 +39,8 @@ TWO_STRINGS(dex,importaddress,symbol,address); TWO_STRINGS(dex,validateaddress,symbol,address); TWO_STRINGS(dex,listunspent,symbol,address); TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions,symbol,address,count,skip); +TWO_STRINGS(dex,kvsearch,symbol,key); +THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb); TWO_STRINGS(zcash,passthru,function,hex); TWO_STRINGS(komodo,passthru,function,hex); From 1a8d207613b518eceef38c3932e7fe22667d8aba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Jan 2017 12:14:19 +0200 Subject: [PATCH 4/8] disable kvupdate --- iguana/iguana_notary.c | 4 +++- iguana/tests/dexkvsearch | 2 ++ iguana/tests/dexkvupdate | 2 ++ includes/iguana_apideclares.h | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100755 iguana/tests/dexkvsearch create mode 100755 iguana/tests/dexkvupdate diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index cdf4fd669..6654c8c9d 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -674,10 +674,12 @@ TWO_STRINGS(dex,kvsearch,symbol,key) return(_dex_kvsearch(myinfo,symbol,key)); } -THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb) +/*THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb) { return(_dex_kvupdate(myinfo,symbol,key,value,flags)); } + need to have some micropayments between client/server, otherwise receiving server incurs costs + */ #include "../includes/iguana_apiundefs.h" diff --git a/iguana/tests/dexkvsearch b/iguana/tests/dexkvsearch new file mode 100755 index 000000000..3c14a2beb --- /dev/null +++ b/iguana/tests/dexkvsearch @@ -0,0 +1,2 @@ +#!/bin/bash +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"foo\",\"symbol\":\"KMD\"}" diff --git a/iguana/tests/dexkvupdate b/iguana/tests/dexkvupdate new file mode 100755 index 000000000..e996ff5ec --- /dev/null +++ b/iguana/tests/dexkvupdate @@ -0,0 +1,2 @@ +#!/bin/bash +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvupdate\",\"key\":\"foo\",\"value\":\"$1\",\"flags\":0,\"symbol\":\"KMD\"}" diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index cd70955cb..ee87e806d 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -40,7 +40,7 @@ TWO_STRINGS(dex,validateaddress,symbol,address); TWO_STRINGS(dex,listunspent,symbol,address); TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions,symbol,address,count,skip); TWO_STRINGS(dex,kvsearch,symbol,key); -THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb); +//THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb); TWO_STRINGS(zcash,passthru,function,hex); TWO_STRINGS(komodo,passthru,function,hex); From cd935314cbb1ea98a845593be8523ab28daa6419 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Jan 2017 12:18:25 +0200 Subject: [PATCH 5/8] test --- iguana/iguana_notary.c | 19 +++++++++++++++---- includes/iguana_apideclares.h | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 6654c8c9d..39e592f2b 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -671,15 +671,26 @@ STRING_ARG(dex,getnotaries,symbol) TWO_STRINGS(dex,kvsearch,symbol,key) { + if ( key == 0 || key[0] == 0 ) + return(clonestr("{\"error\":\"kvsearch parameter error\"}")); return(_dex_kvsearch(myinfo,symbol,key)); } -/*THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb) +THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb) { - return(_dex_kvupdate(myinfo,symbol,key,value,flags)); + // need to have some micropayments between client/server, otherwise receiving server incurs costs + if ( key == 0 || key[0] == 0 || value == 0 || value[0] == 0 ) + return(clonestr("{\"error\":\"kvupdate parameter error\"}")); + if ( strcmp(symbol,"KV") == 0 ) + { + if ( flags > 1 ) + return(clonestr("{\"error\":\"only single duration updates via remote access\"}")); + else if ( strlen(key) > 64 || strlen(value) > 256 ) + return(clonestr("{\"error\":\"only keylen <=64 and valuesize <= 256 allowed via remote access\"}")); + else return(_dex_kvupdate(myinfo,symbol,key,value,flags)); + } else return(clonestr("{\"error\":\"free updates only on KV chain\"}")); } - need to have some micropayments between client/server, otherwise receiving server incurs costs - */ + #include "../includes/iguana_apiundefs.h" diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index ee87e806d..cd70955cb 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -40,7 +40,7 @@ TWO_STRINGS(dex,validateaddress,symbol,address); TWO_STRINGS(dex,listunspent,symbol,address); TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions,symbol,address,count,skip); TWO_STRINGS(dex,kvsearch,symbol,key); -//THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb); +THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb); TWO_STRINGS(zcash,passthru,function,hex); TWO_STRINGS(komodo,passthru,function,hex); From 12d8bcdf11e381891ec63bd081607e691586185b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Jan 2017 12:28:07 +0200 Subject: [PATCH 6/8] test --- iguana/dpow/dpow_network.c | 1 + iguana/dpow/dpow_rpc.c | 1 + iguana/tests/dexkvsearch | 1 + iguana/tests/dexkvupdate | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 5d49799c6..58249fee5 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -773,6 +773,7 @@ char *_dex_kvupdate(struct supernet_info *myinfo,char *symbol,char *key,char *va valuesize = (int32_t)strlen(value); dexreq.shortarg = keylen+1; memcpy(&keyvalue[dexreq.shortarg],value,valuesize+1); + printf("_DEX.(%s) -> (%s) flags.%d\n",key,value,flags); return(_dex_sendrequeststr(myinfo,&dexreq,keyvalue,1,"")); } diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 953c2d388..8add9884b 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -416,6 +416,7 @@ cJSON *dpow_kvupdate(struct supernet_info *myinfo,struct iguana_info *coin,char if ( coin->FULLNODE < 0 ) { sprintf(params,"[\"%s\", \"%s\", \"%d\"]",key,value,flags); + printf("KVUPDATE.%s\n",params); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"kvupdate",params); if ( (retjson= cJSON_Parse(retstr)) == 0 ) { diff --git a/iguana/tests/dexkvsearch b/iguana/tests/dexkvsearch index 3c14a2beb..201ac6352 100755 --- a/iguana/tests/dexkvsearch +++ b/iguana/tests/dexkvsearch @@ -1,2 +1,3 @@ #!/bin/bash curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"foo\",\"symbol\":\"KMD\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"test\",\"symbol\":\"KV\"}" diff --git a/iguana/tests/dexkvupdate b/iguana/tests/dexkvupdate index e996ff5ec..a98240995 100755 --- a/iguana/tests/dexkvupdate +++ b/iguana/tests/dexkvupdate @@ -1,2 +1,3 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvupdate\",\"key\":\"foo\",\"value\":\"$1\",\"flags\":0,\"symbol\":\"KMD\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvupdate\",\"key\":\"test\",\"value\":\"$1\",\"flags\":0,\"symbol\":\"KMD\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvupdate\",\"key\":\"test\",\"value\":\"$1\",\"flags\":0,\"symbol\":\"KV\"}" From e2fe372b4daf621bd51e5484d8cfac031ba5b2d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 21 Jan 2017 12:34:35 +0200 Subject: [PATCH 7/8] test --- iguana/dpow/dpow_network.c | 25 +++++++++++++------------ iguana/iguana_notary.c | 3 +++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 58249fee5..b102cf6f7 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -723,15 +723,16 @@ char *_dex_sendrequest(struct supernet_info *myinfo,struct dex_request *dexreq,i } else return(clonestr("{\"error\":\"not notarychain\"}")); } -char *_dex_sendrequeststr(struct supernet_info *myinfo,struct dex_request *dexreq,char *str,int32_t M,char *field) +char *_dex_sendrequeststr(struct supernet_info *myinfo,struct dex_request *dexreq,char *str,int32_t slen,int32_t M,char *field) { - uint8_t *packet; int32_t datalen,slen; char *retstr; + uint8_t *packet; int32_t datalen; char *retstr; if ( iguana_isnotarychain(dexreq->name) >= 0 ) { - slen = (int32_t)strlen(str)+1; + if ( slen == 0 ) + slen = (int32_t)strlen(str)+1; packet = calloc(1,sizeof(*dexreq)+slen); datalen = dex_rwrequest(1,packet,dexreq); - strcpy((char *)&packet[datalen],str); + memcpy((char *)&packet[datalen],str,slen); datalen += slen; retstr = dex_reqsend(myinfo,"request",packet,datalen,M,field); free(packet); @@ -774,7 +775,7 @@ char *_dex_kvupdate(struct supernet_info *myinfo,char *symbol,char *key,char *va dexreq.shortarg = keylen+1; memcpy(&keyvalue[dexreq.shortarg],value,valuesize+1); printf("_DEX.(%s) -> (%s) flags.%d\n",key,value,flags); - return(_dex_sendrequeststr(myinfo,&dexreq,keyvalue,1,"")); + return(_dex_sendrequeststr(myinfo,&dexreq,keyvalue,keylen+valuesize+2,1,"")); } char *_dex_kvsearch(struct supernet_info *myinfo,char *symbol,char *key) @@ -783,7 +784,7 @@ char *_dex_kvsearch(struct supernet_info *myinfo,char *symbol,char *key) memset(&dexreq,0,sizeof(dexreq)); safecopy(dexreq.name,symbol,sizeof(dexreq.name)); dexreq.func = 'k'; - return(_dex_sendrequeststr(myinfo,&dexreq,key,1,"")); + return(_dex_sendrequeststr(myinfo,&dexreq,key,0,1,"")); } char *_dex_getinfo(struct supernet_info *myinfo,char *symbol) @@ -880,7 +881,7 @@ char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *si memset(&dexreq,0,sizeof(dexreq)); safecopy(dexreq.name,symbol,sizeof(dexreq.name)); dexreq.func = 'S'; - return(_dex_sendrequeststr(myinfo,&dexreq,signedtx,3,"*")); + return(_dex_sendrequeststr(myinfo,&dexreq,signedtx,0,3,"*")); } char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address) @@ -889,7 +890,7 @@ char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address memset(&dexreq,0,sizeof(dexreq)); safecopy(dexreq.name,symbol,sizeof(dexreq.name)); dexreq.func = 'A'; - return(_dex_sendrequeststr(myinfo,&dexreq,address,1,"")); + return(_dex_sendrequeststr(myinfo,&dexreq,address,0,1,"")); } char *_dex_checkaddress(struct supernet_info *myinfo,char *symbol,char *address) @@ -898,7 +899,7 @@ char *_dex_checkaddress(struct supernet_info *myinfo,char *symbol,char *address) memset(&dexreq,0,sizeof(dexreq)); safecopy(dexreq.name,symbol,sizeof(dexreq.name)); dexreq.func = 'C'; - return(_dex_sendrequeststr(myinfo,&dexreq,address,3,"address")); + return(_dex_sendrequeststr(myinfo,&dexreq,address,0,3,"address")); } char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address) @@ -907,7 +908,7 @@ char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *addre memset(&dexreq,0,sizeof(dexreq)); safecopy(dexreq.name,symbol,sizeof(dexreq.name)); dexreq.func = 'V'; - return(_dex_sendrequeststr(myinfo,&dexreq,address,1,"")); + return(_dex_sendrequeststr(myinfo,&dexreq,address,0,1,"")); } char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address) @@ -916,7 +917,7 @@ char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address) memset(&dexreq,0,sizeof(dexreq)); safecopy(dexreq.name,symbol,sizeof(dexreq.name)); dexreq.func = 'U'; - if ( (retstr= _dex_sendrequeststr(myinfo,&dexreq,address,1,"")) != 0 ) + if ( (retstr= _dex_sendrequeststr(myinfo,&dexreq,address,0,1,"")) != 0 ) { //printf("UNSPENTS.(%s)\n",retstr); } @@ -931,7 +932,7 @@ char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *addr dexreq.intarg = skip; dexreq.shortarg = count; dexreq.func = 'L'; - return(_dex_arrayreturn(_dex_sendrequeststr(myinfo,&dexreq,address,1,""))); + return(_dex_arrayreturn(_dex_sendrequeststr(myinfo,&dexreq,address,0,1,""))); } int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 39e592f2b..da09f9d33 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -509,6 +509,8 @@ STRING_AND_INT(dpow,fundnotaries,symbol,numblocks) { if ( symbol == 0 || symbol[0] == 0 || strcmp(symbol,NOTARY_CURRENCIES[i]) == 0 ) { + if ( symbol != 0 && strcmp(symbol,"KV") == 0 ) + val = 100; for (j=0; j Date: Sat, 21 Jan 2017 13:02:07 +0200 Subject: [PATCH 8/8] test --- iguana/dpow/dpow_network.c | 2 +- iguana/dpow/dpow_rpc.c | 2 +- iguana/iguana_notary.c | 6 +++++- iguana/tests/dexkvsearch | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index b102cf6f7..d224f3e29 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -774,7 +774,7 @@ char *_dex_kvupdate(struct supernet_info *myinfo,char *symbol,char *key,char *va valuesize = (int32_t)strlen(value); dexreq.shortarg = keylen+1; memcpy(&keyvalue[dexreq.shortarg],value,valuesize+1); - printf("_DEX.(%s) -> (%s) flags.%d\n",key,value,flags); + //printf("_DEX.(%s) -> (%s) flags.%d\n",key,value,flags); return(_dex_sendrequeststr(myinfo,&dexreq,keyvalue,keylen+valuesize+2,1,"")); } diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 8add9884b..4500ada34 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -416,7 +416,7 @@ cJSON *dpow_kvupdate(struct supernet_info *myinfo,struct iguana_info *coin,char if ( coin->FULLNODE < 0 ) { sprintf(params,"[\"%s\", \"%s\", \"%d\"]",key,value,flags); - printf("KVUPDATE.%s\n",params); + //printf("KVUPDATE.%s\n",params); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"kvupdate",params); if ( (retjson= cJSON_Parse(retstr)) == 0 ) { diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index da09f9d33..e3eab5785 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -690,7 +690,11 @@ THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb) return(clonestr("{\"error\":\"only single duration updates via remote access\"}")); else if ( strlen(key) > 64 || strlen(value) > 256 ) return(clonestr("{\"error\":\"only keylen <=64 and valuesize <= 256 allowed via remote access\"}")); - else return(_dex_kvupdate(myinfo,symbol,key,value,flags)); + else + { + //printf("call _dex_kvupdate.(%s) -> (%s) flags.%d\n",key,value,flags); + return(_dex_kvupdate(myinfo,symbol,key,value,flags)); + } } else return(clonestr("{\"error\":\"free updates only on KV chain\"}")); } diff --git a/iguana/tests/dexkvsearch b/iguana/tests/dexkvsearch index 201ac6352..178a08c42 100755 --- a/iguana/tests/dexkvsearch +++ b/iguana/tests/dexkvsearch @@ -1,3 +1,3 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"foo\",\"symbol\":\"KMD\"}" +#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"foo\",\"symbol\":\"KMD\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"test\",\"symbol\":\"KV\"}"