diff --git a/iguana/exchanges/LP_RTmetrics.c b/iguana/exchanges/LP_RTmetrics.c index ac01d3025..53466e5e7 100644 --- a/iguana/exchanges/LP_RTmetrics.c +++ b/iguana/exchanges/LP_RTmetrics.c @@ -161,7 +161,7 @@ void LP_RTmetrics_update(char *base,char *rel) { if ( (swaps= jarray(&numswaps,statsjson,"swaps")) != 0 ) { - printf("LP_RTmetrics_update for (%s)\n",jprint(swaps,0)); + //printf("LP_RTmetrics_update for (%s)\n",jprint(swaps,0)); if ( numswaps > 0 ) LP_RTmetrics_swapsinfo(base,rel,swaps,numswaps); } diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 9fb48bb7f..b265c8d7b 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -19,10 +19,11 @@ // // if ( G.LP_pendingswaps != 0 ) return(-1); // bot safe to exit? -// +// 324744 and 50mb // BCH signing // single utxo allocations alice // alice waiting for bestprice +// // previously, it used to show amount, kmd equiv, perc // dPoW security -> 4: KMD notarized, 5: BTC notarized, after next notary elections // bigendian architectures need to use little endian for sighash calcs diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index b541200a1..e1f7bf62e 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -889,7 +889,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, price += (r * range) / 100.; bestprice = LP_bob_competition(&counter,aliceid,price,0); printf(">>>>>>>>>>>>> price %.8f qprice %.8f r.%d range %.8f -> %.8f, bestprice %.8f counter.%d\n",ask,qprice,r,range,price,bestprice,counter); - if ( counter > 5 || price > bestprice*1.1 ) // skip if late or bad price + if ( counter > 3 || price > bestprice ) // skip if late or bad price return(retval); } else return(retval); LP_RTmetrics_update(Q.srccoin,Q.destcoin); diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index c0ef0efd7..7889181bf 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1247,29 +1247,6 @@ char *basilisk_swapentry(uint32_t requestid,uint32_t quoteid) if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid)) != 0 ) return(jprint(item,1)); else return(clonestr("{\"error\":\"cant find requestid-quoteid\"}")); - /*if ( (liststr= basilisk_swaplist(requestid,quoteid)) != 0 ) - { - //printf("swapentry.(%s)\n",liststr); - if ( (retjson= cJSON_Parse(liststr)) != 0 ) - { - if ( (array= jarray(&n,retjson,"swaps")) != 0 ) - { - for (i=0; iserverport,coin->userpass,"signrawtransaction",paramstr)) != 0 ) + if ( (0) ) { - if ( (json= cJSON_Parse(retstr)) != 0 ) + array = cJSON_CreateArray(); + jaddistr(array,rawtx); + jaddi(array,jduplicate(vins)); + jaddi(array,jduplicate(privkeys)); + paramstr = jprint(array,1); + //printf("signrawtransaction\n"); + if ( (retstr= bitcoind_passthru(symbol,coin->serverport,coin->userpass,"signrawtransaction",paramstr)) != 0 ) { - if ( (hexstr= jstr(json,"hex")) != 0 ) + if ( (json= cJSON_Parse(retstr)) != 0 ) { - len = (int32_t)strlen(hexstr); - signedtx = calloc(1,len+1); - strcpy(signedtx,hexstr); - *completedp = is_cJSON_True(jobj(json,"complete")); - len >>= 1; - data = malloc(len); - decode_hex(data,len,hexstr); - *signedtxidp = bits256_doublesha256(0,data,len); + if ( (hexstr= jstr(json,"hex")) != 0 ) + { + len = (int32_t)strlen(hexstr); + signedtx = calloc(1,len+1); + strcpy(signedtx,hexstr); + *completedp = is_cJSON_True(jobj(json,"complete")); + len >>= 1; + data = malloc(len); + decode_hex(data,len,hexstr); + *signedtxidp = bits256_doublesha256(0,data,len); + } + //else + printf("%s signrawtransaction.(%s) params.(%s)\n",coin->symbol,retstr,paramstr); + free_json(json); } - //else - printf("%s signrawtransaction.(%s) params.(%s)\n",coin->symbol,retstr,paramstr); - free_json(json); + free(retstr); } - free(retstr); + free(paramstr); + return(signedtx); } - free(paramstr); - return(signedtx); } cJSON *LP_getblock(char *symbol,bits256 txid) @@ -1032,7 +1035,7 @@ uint32_t LP_heighttime(char *symbol,int32_t height) { if ( (retjson= cJSON_Parse(blockhashstr)) != 0 ) { - printf("height.(%s)\n",jprint(retjson,0)); + //printf("height.(%s)\n",jprint(retjson,0)); timestamp = juint(retjson,"time"); free_json(retjson); } @@ -1043,7 +1046,7 @@ uint32_t LP_heighttime(char *symbol,int32_t height) { if ( (retjson= electrum_getheader(coin->symbol,ep,&retjson,height)) != 0 ) { - printf("%s\n",jprint(retjson,0)); + //printf("%s\n",jprint(retjson,0)); timestamp = juint(retjson,"timestamp"); free_json(retjson); } @@ -1074,7 +1077,7 @@ cJSON *LP_blockjson(int32_t *heightp,char *symbol,char *blockhashstr,int32_t hei *heightp = juint(json,"height"); if ( height >= 0 && *heightp != height ) { - printf("unexpected height %d vs %d for %s (%s)\n",*heightp,height,blockhashstr,jprint(json,0)); + //printf("unexpected height %d vs %d for %s (%s)\n",*heightp,height,blockhashstr,jprint(json,0)); *heightp = -1; free_json(json); json = 0; @@ -1255,7 +1258,7 @@ int32_t LP_notarization_latest(int32_t *bestheightp,struct iguana_info *coin) blockhash = jbits256(blockjson,"previousblockhash"); if ( bits256_nonz(blockhash) == 0 ) { - printf("null prev.(%s)\n",jprint(blockjson,0)); + //printf("null prev.(%s)\n",jprint(blockjson,0)); free_json(blockjson); break; } diff --git a/iguana/exchanges/LP_scan.c b/iguana/exchanges/LP_scan.c index 5a5a12051..f3b67476b 100644 --- a/iguana/exchanges/LP_scan.c +++ b/iguana/exchanges/LP_scan.c @@ -466,7 +466,7 @@ int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int { if ( (array= electrum_address_getmempool(symbol,coin->electrum,&array,coinaddr)) != 0 ) { - char str[65]; printf("check %s mempool.(%s)\n",bits256_str(str,txid),jprint(array,0)); + //char str[65]; printf("check %s mempool.(%s)\n",bits256_str(str,txid),jprint(array,0)); if ( (n= cJSON_GetArraySize(array)) > 0 ) { for (i=0; i lasthello+600 ) { char *hellostr,*retstr; cJSON *retjson; int32_t allgood,sock = LP_bindsock; @@ -347,6 +359,94 @@ void issue_LP_uitem(char *destip,uint16_t destport,char *symbol,char *coinaddr,b return(retstr);*/ } +/*if ( (liststr= basilisk_swaplist(requestid,quoteid)) != 0 ) + { + //printf("swapentry.(%s)\n",liststr); + if ( (retjson= cJSON_Parse(liststr)) != 0 ) + { + if ( (array= jarray(&n,retjson,"swaps")) != 0 ) + { + for (i=0; itimestamp = (uint32_t)time(NULL); + ptr->item = item; + item->cjsonid = rand(); + ptr->cjsonid = item->cjsonid; + portable_mutex_lock(&LP_cJSONmutex); + DL_APPEND(LP_cJSONlist,ptr); + portable_mutex_unlock(&LP_cJSONmutex); + } + + void cJSON_unregister(cJSON *item) + { + static uint32_t lasttime; + int32_t n; char *tmpstr; uint64_t total = 0; struct cJSON_list *ptr,*tmp; uint32_t now; + if ( (now= (uint32_t)time(NULL)) > lasttime+6 ) + { + n = 0; + DL_FOREACH_SAFE(LP_cJSONlist,ptr,tmp) + { + if ( ptr->item != 0 && ptr->item->child != 0 && ptr->cjsonid != 0 ) + { + if ( (tmpstr= jprint(ptr->item,0)) != 0 ) + { + total += strlen(tmpstr); + free(tmpstr); + } + } + n++; + } + printf("total %d cJSON pending\n",n); + lasttime = (uint32_t)time(NULL); + } + DL_FOREACH_SAFE(LP_cJSONlist,ptr,tmp) + { + if ( ptr->cjsonid == item->cjsonid ) + break; + else if ( now > ptr->timestamp+60 && item->cjsonid != 0 ) + { + portable_mutex_lock(&LP_cJSONmutex); + DL_DELETE(LP_cJSONlist,ptr); + portable_mutex_unlock(&LP_cJSONmutex); + printf("free expired\n"); + cJSON_Delete(ptr->item); + free(ptr); + } + ptr = 0; + } + if ( ptr != 0 ) + { + portable_mutex_lock(&LP_cJSONmutex); + DL_DELETE(LP_cJSONlist,ptr); + free(ptr); + portable_mutex_unlock(&LP_cJSONmutex); + } //else printf("cJSON_unregister of unknown %p %u\n",item,item->cjsonid); + }*/ char *issue_LP_getprices(char *destip,uint16_t destport) { char url[512]; diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index cfd1a6060..f90a87170 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1651,17 +1651,6 @@ void LP_swap_coinaddr(struct iguana_info *coin,char *coinaddr,uint64_t *valuep,u vout = jitem(vouts,v); if ( valuep != 0 ) *valuep = LP_value_extract(vout,1); - //printf("VOUT.(%s)\n",jprint(vout,0)); - /*if ( (skey= jobj(vout,"scriptPubKey")) != 0 && (addresses= jarray(&m,skey,"addresses")) != 0 ) - { - item = jitem(addresses,0); - //printf("item.(%s)\n",jprint(item,0)); - if ( (addr= jstr(item,0)) != 0 ) - { - safecopy(coinaddr,addr,64); - //printf("extracted.(%s)\n",coinaddr); - } - }*/ LP_destaddr(coinaddr,vout); } free_json(txobj); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index c93f5e0fc..59b8b8b8e 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -27,72 +27,6 @@ struct LP_inuse_info } LP_inuse[1024]; int32_t LP_numinuse; -/*struct cJSON_list -{ - struct cJSON_list *next,*prev; - cJSON *item; - uint32_t timestamp,cjsonid; -} *LP_cJSONlist; - -void cJSON_register(cJSON *item) -{ - struct cJSON_list *ptr; - ptr = calloc(1,sizeof(*ptr)); - ptr->timestamp = (uint32_t)time(NULL); - ptr->item = item; - item->cjsonid = rand(); - ptr->cjsonid = item->cjsonid; - portable_mutex_lock(&LP_cJSONmutex); - DL_APPEND(LP_cJSONlist,ptr); - portable_mutex_unlock(&LP_cJSONmutex); -} - -void cJSON_unregister(cJSON *item) -{ - static uint32_t lasttime; - int32_t n; char *tmpstr; uint64_t total = 0; struct cJSON_list *ptr,*tmp; uint32_t now; - if ( (now= (uint32_t)time(NULL)) > lasttime+6 ) - { - n = 0; - DL_FOREACH_SAFE(LP_cJSONlist,ptr,tmp) - { - if ( ptr->item != 0 && ptr->item->child != 0 && ptr->cjsonid != 0 ) - { - if ( (tmpstr= jprint(ptr->item,0)) != 0 ) - { - total += strlen(tmpstr); - free(tmpstr); - } - } - n++; - } - printf("total %d cJSON pending\n",n); - lasttime = (uint32_t)time(NULL); - } - DL_FOREACH_SAFE(LP_cJSONlist,ptr,tmp) - { - if ( ptr->cjsonid == item->cjsonid ) - break; - else if ( now > ptr->timestamp+60 && item->cjsonid != 0 ) - { - portable_mutex_lock(&LP_cJSONmutex); - DL_DELETE(LP_cJSONlist,ptr); - portable_mutex_unlock(&LP_cJSONmutex); - printf("free expired\n"); - cJSON_Delete(ptr->item); - free(ptr); - } - ptr = 0; - } - if ( ptr != 0 ) - { - portable_mutex_lock(&LP_cJSONmutex); - DL_DELETE(LP_cJSONlist,ptr); - free(ptr); - portable_mutex_unlock(&LP_cJSONmutex); - } //else printf("cJSON_unregister of unknown %p %u\n",item,item->cjsonid); -}*/ - struct LP_inuse_info *_LP_inuse_find(bits256 txid,int32_t vout) { int32_t i;