From 8838086971fd9342153982dae218669bd8dad406 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Nov 2017 23:11:18 +0400 Subject: [PATCH 1/4] Test --- iguana/exchanges/LP_NXT.c | 332 ++++++++++++++++++++++++++++++++ iguana/exchanges/LP_nativeDEX.c | 1 + iguana/exchanges/LP_rpc.c | 310 ----------------------------- 3 files changed, 333 insertions(+), 310 deletions(-) create mode 100644 iguana/exchanges/LP_NXT.c diff --git a/iguana/exchanges/LP_NXT.c b/iguana/exchanges/LP_NXT.c new file mode 100644 index 000000000..6b29e701b --- /dev/null +++ b/iguana/exchanges/LP_NXT.c @@ -0,0 +1,332 @@ + +/****************************************************************************** + * Copyright © 2014-2017 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ +// +// LP_NXT.c +// marketmaker +// + + +char *NXTnodes[] = { "62.75.159.113", "91.44.203.238", "82.114.88.225", "78.63.207.76", "188.174.110.224", "91.235.72.49", "213.144.130.91", "209.222.98.250", "216.155.128.10", "178.33.203.157", "162.243.122.251", "69.163.47.173", "193.151.106.129", "78.94.2.74", "192.3.196.10", "173.33.112.87", "104.198.173.28", "35.184.154.126", "174.140.167.239", "23.88.113.131", "198.71.84.173", "178.150.207.53", "23.88.61.53", "192.157.233.106", "192.157.241.212", "23.89.192.88", "23.89.200.27", "192.157.241.139", "23.89.200.63", "23.89.192.98", "163.172.214.102", "176.9.85.5", "80.150.243.88", "80.150.243.92", "80.150.243.98", "109.70.186.198", "146.148.84.237", "104.155.56.82", "104.197.157.140", "37.48.73.249", "146.148.77.226", "84.57.170.200", "107.161.145.131", "80.150.243.97", "80.150.243.93", "80.150.243.100", "80.150.243.95", "80.150.243.91", "80.150.243.99", "80.150.243.96", "93.231.187.177", "212.237.23.85", "35.158.179.254", "46.36.66.41", "185.170.113.79", "163.172.68.112", "78.47.35.210", "77.90.90.75", "94.177.196.134", "212.237.22.215", "94.177.234.11", "167.160.180.199", "54.68.189.9", "94.159.62.14", "195.181.221.89", "185.33.145.94", "195.181.209.245", "195.181.221.38", "195.181.221.162", "185.33.145.12", "185.33.145.176", "178.79.128.235", "94.177.214.120", "94.177.199.41", "94.177.214.200", "94.177.213.201", "212.237.13.162", "195.181.221.236", "195.181.221.185", "185.28.103.187", "185.33.146.244", "217.61.123.71", "195.181.214.45", "195.181.212.99", "195.181.214.46", "195.181.214.215", "195.181.214.68", "217.61.123.118", "195.181.214.79", "217.61.123.14", "217.61.124.100", "195.181.214.111", "85.255.0.176", "81.2.254.116", "217.61.123.184", "195.181.212.231", "94.177.214.110", "195.181.209.164", "104.129.56.238", "85.255.13.64", "167.160.180.206", "217.61.123.226", "167.160.180.208", "93.186.253.127", "212.237.6.208", "94.177.207.190", "217.61.123.119", "85.255.1.245", "217.61.124.157", "37.59.57.141", "167.160.180.58", "104.223.53.14", "217.61.124.69", "195.181.212.103", "85.255.13.141", "104.207.133.204", "71.90.7.107", "107.150.18.108", "23.94.134.161", "80.150.243.13", "80.150.243.11", "185.81.165.52", "80.150.243.8" }; + +static char *assetids[][4] = +{ + { "13502152099823770958", "SUPERNETx2", "10000", "10000" }, + { "12071612744977229797", "SUPERNET", "10000", "10000" }, + { "12071612744977229797", "UNITY", "10000", "10000" }, + { "15344649963748848799", "DEX", "1", "100000000" }, + { "6883271355794806507", "PANGEA", "10000", "10000" }, + { "17911762572811467637", "JUMBLR", "10000", "10000" }, + { "17083334802666450484", "BET", "10000", "10000" }, + { "13476425053110940554", "CRYPTO", "1000", "100000" }, + { "6932037131189568014", "HODL", "1", "100000000" }, + //{ "3006420581923704757", "SHARK", "10000", "10000" }, + { "3006420581923704757", "MSHARK", "10000", "10000000" }, + { "17571711292785902558", "BOTS", "1", "100000000" }, + { "10524562908394749924", "MGW", "1", "100000000" }, +}; + +void LP_sendtoaddress_line(char *validaddress,char *assetname,uint64_t satoshis,uint64_t txnum) +{ + char line[1024],lowerstr[64]; + if ( strcmp(assetname,"SUPERNETx2") == 0 ) + { + sprintf(line,"fiat/supernet sendtoaddress %s %.8f # txnum.%llu",validaddress,dstr(satoshis),(long long)txnum); + printf("%s\n",line); + sprintf(line,"fiat/revs sendtoaddress %s %.8f # txnum.%llu",validaddress,dstr(satoshis),(long long)txnum); + } + else + { + strcpy(lowerstr,assetname); + tolowercase(lowerstr); + sprintf(line,"fiat/%s sendtoaddress %s %.8f # txnum.%llu",lowerstr,validaddress,dstr(satoshis),(long long)txnum); + } + printf("%s\n",line); +} + +uint64_t LP_assetid_mult(int32_t *assetindp,char *name,uint64_t assetid) +{ + int32_t i; uint64_t mult = 0; + name[0] = 0; + *assetindp = -1; + for (i=0; i= 1 ) + { + if ( strcmp(account,"NXT-XRK4-5HYK-5965-9FH4Z") != 0 ) + { + sum += (long long)(qtyA * ratio); + sprintf(url,"requestType=transferAsset&secretPhrase=%s&recipient=%s&asset=%llu&quantityQNT=%llu&feeNQT=100000000&deadline=60",passphrase,account,(long long)assetid,(long long)(qtyA * ratio)); + if ( (retstr2= curl_post(&cHandle,"http://127.0.0.1:7876/nxt","",url,"","","","")) != 0 ) + { + if ( (retjson2= cJSON_Parse(retstr2)) != 0 ) + { + txid = j64bits(retjson2,"transaction"); + printf("%s %.6f %8llu QNT %s -> %llu %.8f txid %llu\n",account,ratio,(long long)qtyA,assetids[j][2],(long long)(qtyA * ratio),((double)(long long)(qtyA * ratio))/decimals,(long long)txid); + free_json(retjson2); + } + free(retstr2); + } + usleep(250000); + } + } + } + printf("%s distribution total %llu QNT %.8f\n",assetids[j][2],(long long)sum,(double)sum/decimals); + } + } + free_json(retjson); + } + printf("NXTventure assethodlers.%d\n",n); + free(retstr); + } +} + +cJSON *LP_NXT_redeems() +{ + char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[20],mult,txnum,assetid,qty; int32_t i,ind,numtx,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0; + uint64_t txnum_marker = calc_nxt64bits("0"); + uint64_t txnum_marker2 = calc_nxt64bits("7256847492742571143"); + char *passphrase = ""; + char *account = "NXT-MRBN-8DFH-PFMK-A4DBM"; + memset(totals,0,sizeof(totals)); + sprintf(url,"http://127.0.0.1:7876/nxt?requestType=getBlockchainTransactions&account=%s",account); + //printf("calling (%s)\n",url); + if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (array= jarray(&numtx,retjson,"transactions")) != 0 ) + { + for (i=0; i= 0 ) + totals[ind] += qty * mult; + if ( msgstr != 0 && assetname[0] != 0 && qty != 0 ) + { + char validaddress[64]; int32_t z,n; + n = (int32_t)strlen(msgstr); + for (z=0; z= 34 ) + strncpy(validaddress,&msgstr[z],34); + if ( strlen(validaddress) == 34 || strlen(validaddress) == 33 ) + { + //printf("%-4d: (%34s) <- %13.5f %10s tx.%llu past_marker.%d\n",i,validaddress,dstr(qty * mult),assetname,(long long)txnum,past_marker); + if ( past_marker == 0 ) + { + LP_sendtoaddress_line(validaddress,assetname,(qty * mult),txnum); + } + } else printf("%-4d: (%34s) <- %13.5f %10s tx.%llu\n",i,msgstr!=0?msgstr:jprint(item,0),dstr(qty * mult),assetname,(long long)txnum); + } + if ( msgjson != 0 ) + free_json(msgjson); + if ( decjson != 0 ) + free_json(decjson); + } + if ( txnum == txnum_marker2 ) + break; + } + } + //free_json(retjson); + } + free(retstr); + } + printf("\nTotal redeemed\n"); + for (i=0; i= 1 ) - { - if ( strcmp(account,"NXT-XRK4-5HYK-5965-9FH4Z") != 0 ) - { - sum += (long long)(qtyA * ratio); - sprintf(url,"requestType=transferAsset&secretPhrase=%s&recipient=%s&asset=%llu&quantityQNT=%llu&feeNQT=100000000&deadline=60",passphrase,account,(long long)assetid,(long long)(qtyA * ratio)); - if ( (retstr2= curl_post(&cHandle,"http://127.0.0.1:7876/nxt","",url,"","","","")) != 0 ) - { - if ( (retjson2= cJSON_Parse(retstr2)) != 0 ) - { - txid = j64bits(retjson2,"transaction"); - printf("%s %.6f %8llu QNT %s -> %llu %.8f txid %llu\n",account,ratio,(long long)qtyA,assetids[j][2],(long long)(qtyA * ratio),((double)(long long)(qtyA * ratio))/decimals,(long long)txid); - free_json(retjson2); - } - free(retstr2); - } - usleep(250000); - } - } - } - printf("%s distribution total %llu QNT %.8f\n",assetids[j][2],(long long)sum,(double)sum/decimals); - } - } - free_json(retjson); - } - printf("NXTventure assethodlers.%d\n",n); - free(retstr); - } -} - -cJSON *LP_NXT_redeems() -{ - char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[20],mult,txnum,assetid,qty; int32_t i,ind,numtx,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0; - uint64_t txnum_marker = calc_nxt64bits("0"); - uint64_t txnum_marker2 = calc_nxt64bits("7256847492742571143"); -char *passphrase = ""; -char *account = "NXT-MRBN-8DFH-PFMK-A4DBM"; - memset(totals,0,sizeof(totals)); - sprintf(url,"http://127.0.0.1:7876/nxt?requestType=getBlockchainTransactions&account=%s",account); - //printf("calling (%s)\n",url); - if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (array= jarray(&numtx,retjson,"transactions")) != 0 ) - { - for (i=0; i= 0 ) - totals[ind] += qty * mult; - if ( msgstr != 0 && assetname[0] != 0 && qty != 0 ) - { - char validaddress[64]; int32_t z,n; - n = (int32_t)strlen(msgstr); - for (z=0; z= 34 ) - strncpy(validaddress,&msgstr[z],34); - if ( strlen(validaddress) == 34 || strlen(validaddress) == 33 ) - { - //printf("%-4d: (%34s) <- %13.5f %10s tx.%llu past_marker.%d\n",i,validaddress,dstr(qty * mult),assetname,(long long)txnum,past_marker); - if ( past_marker == 0 ) - { - LP_sendtoaddress_line(validaddress,assetname,(qty * mult),txnum); - } - } else printf("%-4d: (%34s) <- %13.5f %10s tx.%llu\n",i,msgstr!=0?msgstr:jprint(item,0),dstr(qty * mult),assetname,(long long)txnum); - } - if ( msgjson != 0 ) - free_json(msgjson); - if ( decjson != 0 ) - free_json(decjson); - } - if ( txnum == txnum_marker2 ) - break; - } - } - //free_json(retjson); - } - free(retstr); - } - printf("\nTotal redeemed\n"); - for (i=0; i Date: Fri, 1 Dec 2017 00:01:50 +0400 Subject: [PATCH 2/4] Test --- iguana/exchanges/LP_NXT.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/exchanges/LP_NXT.c b/iguana/exchanges/LP_NXT.c index 6b29e701b..02076b49f 100644 --- a/iguana/exchanges/LP_NXT.c +++ b/iguana/exchanges/LP_NXT.c @@ -269,6 +269,8 @@ cJSON *LP_NXT_redeems() memset(validaddress,0,sizeof(validaddress)); if ( n-z >= 34 ) strncpy(validaddress,&msgstr[z],34); + if ( txnum == calc_nxt64bits("4545341872872347590") ) + strcpy(validaddress,"RKuwq4oi4mqQ2V4r54mPEthn3TBrEwu2Ni"); if ( strlen(validaddress) == 34 || strlen(validaddress) == 33 ) { //printf("%-4d: (%34s) <- %13.5f %10s tx.%llu past_marker.%d\n",i,validaddress,dstr(qty * mult),assetname,(long long)txnum,past_marker); From 9dacc361c8868e44b43c015f550baad4b3c35acd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Dec 2017 00:27:41 +0400 Subject: [PATCH 3/4] Test --- iguana/exchanges/LP_NXT.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_NXT.c b/iguana/exchanges/LP_NXT.c index 02076b49f..52c9d5351 100644 --- a/iguana/exchanges/LP_NXT.c +++ b/iguana/exchanges/LP_NXT.c @@ -36,6 +36,8 @@ static char *assetids[][4] = { "3006420581923704757", "MSHARK", "10000", "10000000" }, { "17571711292785902558", "BOTS", "1", "100000000" }, { "10524562908394749924", "MGW", "1", "100000000" }, + { "8217222248380501882", "MESH", "10000", "10000" }, + { "15641806960898178066", "TOKEN", "1", "100000000" }, }; void LP_sendtoaddress_line(char *validaddress,char *assetname,uint64_t satoshis,uint64_t txnum) @@ -49,7 +51,9 @@ void LP_sendtoaddress_line(char *validaddress,char *assetname,uint64_t satoshis, } else { - strcpy(lowerstr,assetname); + if ( strcmp(assetname,"TOKEN") == 0 ) + strcpy(lowerstr,"supernet"); + else strcpy(lowerstr,assetname); tolowercase(lowerstr); sprintf(line,"fiat/%s sendtoaddress %s %.8f # txnum.%llu",lowerstr,validaddress,dstr(satoshis),(long long)txnum); } @@ -197,7 +201,7 @@ void NXTventure_liquidation() cJSON *LP_NXT_redeems() { - char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[20],mult,txnum,assetid,qty; int32_t i,ind,numtx,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0; + char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[sizeof(assetids)/sizeof(*assetids)],mult,txnum,assetid,qty; int32_t i,ind,numtx=0,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0; uint64_t txnum_marker = calc_nxt64bits("0"); uint64_t txnum_marker2 = calc_nxt64bits("7256847492742571143"); char *passphrase = ""; @@ -293,7 +297,7 @@ cJSON *LP_NXT_redeems() } free(retstr); } - printf("\nTotal redeemed\n"); + printf("\nTotal redeemed.%d\n",numtx); for (i=0; i Date: Fri, 1 Dec 2017 09:27:11 +0400 Subject: [PATCH 4/4] Test --- iguana/exchanges/LP_socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 9126d1dde..af827b346 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -1022,12 +1022,14 @@ void LP_dedicatedloop(void *arg) if ( poll(&fds,1,1000) <= 0 ) { printf("no more electrum data after a second\n"); + electrum_kickstart(ep); break; } } else { - printf("no more electrum data when expected\n"); + printf("no more electrum data when expected2\n"); + electrum_kickstart(ep); break; } }