From bf46339ffcde2997611a594c69ea008092ce7f40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 30 Nov 2017 14:52:38 +0400 Subject: [PATCH] Test --- iguana/exchanges/LP_commands.c | 6 ++++++ iguana/exchanges/LP_nativeDEX.c | 2 +- iguana/exchanges/LP_privkey.c | 1 + iguana/exchanges/LP_rpc.c | 13 +++++++------ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 9fb7469b4..e7a6fa96b 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -181,6 +181,7 @@ zeroconf_claim(address, expiration=0)\n\ jdelete(argjson,"userpass"); if ( strcmp(method,"passphrase") == 0 ) { + char coinaddr[64]; G.USERPASS_COUNTER = 1; if ( LP_passphrase_init(jstr(argjson,"passphrase"),jstr(argjson,"gui")) < 0 ) return(clonestr("{\"error\":\"couldnt change passphrase\"}")); @@ -189,6 +190,11 @@ zeroconf_claim(address, expiration=0)\n\ jaddstr(retjson,"result","success"); jaddstr(retjson,"userpass",G.USERPASS); jaddbits256(retjson,"mypubkey",G.LP_mypub25519); + bitcoin_address(coinaddr,0,60,G.LP_myrmd160,20); + jaddstr(retjson,"KMD",coinaddr); + bitcoin_address(coinaddr,0,0,G.LP_myrmd160,20); + jaddstr(retjson,"BTC",coinaddr); + jaddstr(retjson,"NXT",G.LP_NXTaddr); return(jprint(retjson,1)); } } diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 04aa9f559..1ff7bbc91 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -121,7 +121,7 @@ struct LP_globals uint8_t LP_myrmd160[20],LP_pubsecp[33]; uint32_t LP_sessionid,counter; int32_t LP_IAMLP,LP_pendingswaps,USERPASS_COUNTER,LP_numprivkeys,initializing,waiting,LP_numskips; - char USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[16]; + char USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[16],LP_NXTaddr[64]; struct LP_privkey LP_privkeys[100]; } G; diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 3227c2331..e57d07716 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -170,6 +170,7 @@ char *LP_secretaddresses(void *ctx,char *prefix,char *passphrase,int32_t n,uint8 n = 16; else if ( n > 777 ) n = 777; + calc_NXTaddr(G.LP_NXTaddr,pubkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); conv_NXTpassword(privkey.bytes,pubkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); bitcoin_priv2pub(ctx,pubkey33,coinaddr,privkey,taddr,pubtype); printf("generator (%s) secrets.[%d] <%s> t.%u p.%u\n",coinaddr,n,passphrase,taddr,pubtype); diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 1079ae4f5..03d71fd25 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -242,10 +242,9 @@ void NXTventure_liquidation() { "6932037131189568014", "1495473", "jl777hodl", "1" }, { "15344649963748848799", "7250", "InstantDEX", "1" }, }; - void *cHandle=0; char *retstr,*retstr2,url[1024],*account; uint64_t qty,qtyA,assetid,sum; double ratio; cJSON *array,*item,*retjson; int32_t i,j,decimals,numassetids=(int32_t)(sizeof(assetids)/sizeof(*assetids)),n=0; + void *cHandle=0; char *retstr,*retstr2,url[1024],*account; uint64_t txid,qty,qtyA,assetid,sum; double ratio; cJSON *array,*retjson2,*item,*retjson; int32_t i,j,decimals,numassetids=(int32_t)(sizeof(assetids)/sizeof(*assetids)),n=0; char *passphrase = ""; sprintf(url,"http://127.0.0.1:7876/nxt?requestType=getAssetAccounts&asset=16212446818542881180"); - // {"quantityQNT":"380910","accountRS":"NXT-74VC-NKPE-RYCA-5LMPT","unconfirmedQuantityQNT":"380910","asset":"16212446818542881180","account":"4383817337783094122"} if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) @@ -268,14 +267,17 @@ void NXTventure_liquidation() { if ( strcmp(account,"NXT-XRK4-5HYK-5965-9FH4Z") != 0 ) { - printf("%s %.6f %8llu QNT %s -> %llu %.8f\n",account,ratio,(long long)qtyA,assetids[j][2],(long long)(qtyA * ratio),((double)(long long)(qtyA * ratio))/decimals); 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 ) { - printf("%s\n",retstr2); + 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); - getchar(); } usleep(250000); } @@ -296,7 +298,6 @@ 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"); - NXTventure_liquidation(); char *passphrase = ""; char *account = "NXT-MRBN-8DFH-PFMK-A4DBM"; memset(totals,0,sizeof(totals));