Browse Source

Merge branch 'dev' of https://github.com/jl777/SuperNET into dev-decker-dev

patch-3
DeckerSU 7 years ago
parent
commit
77c5eb3201
  1. 4
      iguana/exchanges/LP_cache.c
  2. 1
      iguana/exchanges/LP_coins.c
  3. 8
      iguana/exchanges/LP_include.h
  4. 11
      iguana/exchanges/LP_nativeDEX.c
  5. 55
      iguana/exchanges/LP_network.c
  6. 8
      iguana/exchanges/LP_ordermatch.c
  7. 4
      iguana/exchanges/LP_privkey.c
  8. 2
      iguana/exchanges/LP_signatures.c
  9. 6
      iguana/exchanges/LP_socket.c
  10. 10
      iguana/exchanges/LP_transaction.c
  11. 72
      iguana/exchanges/LP_utxo.c
  12. 2
      iguana/exchanges/stats.c

4
iguana/exchanges/LP_cache.c

@ -57,7 +57,7 @@ struct LP_transaction *LP_create_transaction(struct iguana_info *coin,bits256 tx
tx->outpoints[i].interest = SATOSHIDEN * jdouble(vout,"interest");
LP_destaddr(tx->outpoints[i].coinaddr,vout);
//printf("from transaction init %s %s %s/v%d <- %.8f\n",coin->symbol,tx->outpoints[i].coinaddr,bits256_str(str,txid),i,dstr(tx->outpoints[i].value));
LP_address_utxoadd((uint32_t)time(NULL),"LP_create_transaction",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_create_transaction",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1);
}
for (i=0; i<numvins; i++)
{
@ -75,7 +75,7 @@ struct LP_transaction *LP_create_transaction(struct iguana_info *coin,bits256 tx
tx->outpoints[spentvout].spendtxid = txid;
tx->outpoints[spentvout].spendvini = i;
tx->outpoints[spentvout].spendheight = height > 0 ? height : 1;
LP_address_utxoadd((uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1);
if ( 0 && strcmp(coin->symbol,"REVS") == 0 )
printf("spend %s %s/v%d at ht.%d\n",coin->symbol,bits256_str(str,tx->txid),spentvout,height);
}

1
iguana/exchanges/LP_coins.c

@ -342,6 +342,7 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata)
*coin = *cdata;
portable_mutex_init(&coin->txmutex);
portable_mutex_init(&coin->addrmutex);
portable_mutex_init(&coin->addressutxo_mutex);
portable_mutex_lock(&LP_coinmutex);
HASH_ADD_KEYPTR(hh,LP_coins,coin->symbol,strlen(coin->symbol),coin);
portable_mutex_unlock(&LP_coinmutex);

8
iguana/exchanges/LP_include.h

@ -56,7 +56,7 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping
#define LP_MAXVINS 64
#define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL)
#define LP_AUTOTRADE_TIMEOUT 60
#define LP_AUTOTRADE_TIMEOUT 180
#define LP_RESERVETIME 600 //(LP_AUTOTRADE_TIMEOUT * 2)
#define ELECTRUM_TIMEOUT 13
#define LP_ELECTRUM_KEEPALIVE 60
@ -298,9 +298,9 @@ struct LP_transaction
struct iguana_info
{
UT_hash_handle hh;
portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses;
portable_mutex_t txmutex,addrmutex,addressutxo_mutex; struct LP_transaction *transactions; struct LP_address *addresses;
uint64_t txfee;
int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport;
int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport,did_addrutxo_reset;
uint32_t txversion,dPoWtime,lastresetutxo,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime;
uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms;
char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64];
@ -535,7 +535,7 @@ int32_t LP_numpeers();
double LP_CMCbtcprice(double *price_usdp,char *symbol);
char *basilisk_swapentry(uint32_t requestid,uint32_t quoteid,int32_t forceflag);
int64_t LP_KMDvalue(struct iguana_info *coin,int64_t balance);
int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight);
int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight);
void LP_smartutxos_push(struct iguana_info *coin);
void LP_cacheptrs_init(struct iguana_info *coin);
cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrumret);

11
iguana/exchanges/LP_nativeDEX.c

@ -554,6 +554,11 @@ void LP_coinsloop(void *_coins)
memset(&zero,0,sizeof(zero));
if ( coin->inactive != 0 )
continue;
if ( coin->did_addrutxo_reset == 0 )
{
LP_address_utxo_reset(coin);
coin->did_addrutxo_reset = 1;
}
if ( coin->longestchain == 1 ) // special init value
coin->longestchain = LP_getheight(&notarized,coin);
if ( (ep= coin->electrum) != 0 )
@ -1166,13 +1171,13 @@ int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,cha
{
if ( (sentbytes= nn_send(pubp->pairsock,msg,(int32_t)strlen(msg)+1,0)) < 0 )
{
pubp->pairsock = -1;
LP_peer_pairsock(pubkey);
//pubp->pairsock = -1;
//LP_peer_pairsock(pubkey);
//printf("mark cmdchannel %d closed sentbytes.%d\n",pubp->pairsock,sentbytes);
}
else
{
//printf("sent %d bytes to cmdchannel.%d\n",sentbytes,pubp->pairsock);
printf("sent %d bytes to cmdchannel.%d\n",sentbytes,pubp->pairsock);
return(sentbytes);
}
}

55
iguana/exchanges/LP_network.c

@ -596,7 +596,7 @@ void LP_psockloop(void *_ptr)
} // else printf("num pfds.%d retval.%d\n",n,retval);
}
}
if ( sendsock >= 0 )
if ( 0 && sendsock >= 0 )
printf("sendsock.%d Numpsocks.%d\n",sendsock,Numpsocks);
if ( sendsock < 0 )
{
@ -686,6 +686,38 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_
int32_t i,pullsock,bindflag=(IAMLP != 0),pubsock,arg; struct LP_pubkey_info *pubp; char pushaddr[128],subaddr[128]; cJSON *retjson = 0;
pullsock = pubsock = -1;
*pullsockp = *pubsockp = -1;
if ( IAMLP != 0 && bits256_nonz(pubkey) != 0 )
{
char str[65];
if ( (pubp= LP_pubkeyadd(pubkey)) != 0 )
{
if ( pubp->pairsock >= 0 )
{
printf("%s already has pairsock.%d\n",bits256_str(str,pubkey),pubp->pairsock);
for (i=0; i<Numpsocks; i++)
if ( PSOCKS[i].publicsock == pubp->pairsock )
{
//PSOCKS[i].lasttime = (uint32_t)time(NULL) - PSOCK_KEEPALIVE - 1;
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddstr(retjson,"LPipaddr",ipaddr);
jaddstr(retjson,"connectaddr",PSOCKS[i].sendaddr);
jaddnum(retjson,"connectport",PSOCKS[i].sendport);
jaddnum(retjson,"ispaired",PSOCKS[i].ispaired);
jaddnum(retjson,"cmdchannel",PSOCKS[i].cmdchannel);
jaddstr(retjson,"publicaddr",PSOCKS[i].publicaddr);
jaddnum(retjson,"publicport",PSOCKS[i].publicport);
//printf("cmd.%d publicaddr.(%s) for subaddr.(%s), pullsock.%d pubsock.%d\n",cmdchannel,pushaddr,subaddr,pullsock,pubsock);
*pullsockp = pullsock;
*pubsockp = pubsock;
return(jprint(retjson,1));
}
LP_psockadd(ispaired,pullsock,publicport,pubsock,subport,subaddr,pushaddr,cmdchannel);
}
//printf("pairsock for %s <- %d\n",bits256_str(str,pubkey),pullsock);
//pubp->pairsock = pullsock;
}
}
nanomsg_transportname(bindflag,pushaddr,ipaddr,publicport);
nanomsg_transportname(bindflag,subaddr,ipaddr,subport);
if ( (pullsock= nn_socket(AF_SP,ispaired!=0?NN_PAIR:NN_PULL)) >= 0 && (cmdchannel != 0 ||(pubsock= nn_socket(AF_SP,ispaired!=0?NN_PAIR:NN_PAIR)) >= 0) )
@ -707,25 +739,6 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_
nanomsg_transportname(0,pushaddr,ipaddr,publicport);
nanomsg_transportname(0,subaddr,ipaddr,subport);
LP_psockadd(ispaired,pullsock,publicport,pubsock,subport,subaddr,pushaddr,cmdchannel);
if ( IAMLP != 0 && bits256_nonz(pubkey) != 0 )
{
char str[65];
if ( (pubp= LP_pubkeyadd(pubkey)) != 0 )
{
if ( pubp->pairsock >= 0 )
{
//printf("warning %s already has pairsock.%d, mark for purge\n",bits256_str(str,pubkey),pubp->pairsock);
for (i=0; i<Numpsocks; i++)
if ( PSOCKS[i].publicsock == pubp->pairsock )
{
PSOCKS[i].lasttime = (uint32_t)time(NULL) - PSOCK_KEEPALIVE - 1;
break;
}
}
printf("pairsock for %s <- %d\n",bits256_str(str,pubkey),pullsock);
pubp->pairsock = pullsock;
}
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddstr(retjson,"LPipaddr",ipaddr);
@ -804,7 +817,7 @@ char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmd
char str[65],url[512],*retstr;
sprintf(url,"http://%s:%u/api/stats/psock?ispaired=%d&cmdchannel=%d&pubkey=%s",destip,destport-1,ispaired,cmdchannel,bits256_str(str,G.LP_mypub25519));
//return(LP_issue_curl("psock",destip,destport,url));
retstr = issue_curlt(url,LP_HTTP_TIMEOUT*3);
retstr = issue_curlt(url,LP_HTTP_TIMEOUT*10);
printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?!
return(retstr);
}

8
iguana/exchanges/LP_ordermatch.c

@ -230,7 +230,7 @@ int32_t LP_nanobind(void *ctx,char *pairstr)
printf("error creating utxo->pair\n");
else
{
for (i=0; i<10; i++)
for (i=0; i<1000; i++)
{
r = (10000 + (LP_rand() % 50000)) & 0xffff;
if ( LP_fixed_pairport != 0 )
@ -704,7 +704,7 @@ int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout)
if ( vout < tx->numvouts && tx->height > 0 )
{
printf("added missing utxo for SPV checking\n");
LP_address_utxoadd((uint32_t)time(NULL),"LP_validSPV",coin,coinaddr,txid,vout,tx->outpoints[vout].value,tx->height,-1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_validSPV",coin,coinaddr,txid,vout,tx->outpoints[vout].value,tx->height,-1);
}
}
}
@ -873,7 +873,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
return(0);
}
//printf("LP_address_utxo_reset.%s\n",coin->symbol);
LP_address_utxo_reset(coin);
//LP_address_utxo_reset(coin);
//printf("done LP_address_utxo_reset.%s\n",coin->symbol);
if ( (butxo= LP_address_myutxopair(butxo,1,utxos,max,LP_coinfind(qp->srccoin),qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 )
{
@ -1041,7 +1041,7 @@ void LP_tradesloop(void *ctx)
{
//LP_Alicemaxprice = tp->bestprice;
//LP_reserved(ctx,LP_myipaddr,LP_mypubsock,&tp->Qs[LP_CONNECT]); // send LP_CONNECT
printf("mark slow LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice);
//printf("mark slow LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice);
if ( (pubp= LP_pubkeyfind(tp->Qs[LP_CONNECT].srchash)) != 0 )
pubp->slowresponse++;
}

4
iguana/exchanges/LP_privkey.c

@ -317,7 +317,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan
printf("userpass.(%s)\n",bits256_str(G.USERPASS,userpub));
}
}
if ( coin->importedprivkey == 0 && coin->electrum == 0 && coin->userpass[0] != 0 && LP_getheight(&notarized,coin) > 0 )
if ( strcmp(coin->smartaddr,"RPZVpjptzfZnFZZoLnuSbfLexjtkhe6uvn") != 0 && coin->importedprivkey == 0 && coin->electrum == 0 && coin->userpass[0] != 0 && LP_getheight(&notarized,coin) > 0 )
{
memset(zero.bytes,0,sizeof(zero));
LP_listunspent_issue(coin->symbol,coin->smartaddr,0,zero,zero);
@ -417,7 +417,7 @@ int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seedn
LP_priceinfos_clear();
G.USERPASS_COUNTER = counter;
G.initializing = 0;
LP_cmdchannels();
//LP_cmdchannels();
return(0);
}

2
iguana/exchanges/LP_signatures.c

@ -626,7 +626,7 @@ printf("LP_uitem_recv deprecated\n");
{
//char str[65]; printf("uitem %s %s %s/v%d %.8f ht.%d\n",symbol,coinaddr,bits256_str(str,txid),vout,dstr(value),height);
if ( strcmp(coin->smartaddr,coinaddr) != 0 )
LP_address_utxoadd((uint32_t)time(NULL),"LP_uitem_recv",coin,coinaddr,txid,vout,value,height,-1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_uitem_recv",coin,coinaddr,txid,vout,value,height,-1);
//else printf("ignore external uitem %s %s\n",symbol,coin->smartaddr);
}
return(clonestr("{\"result\":\"success\"}"));

6
iguana/exchanges/LP_socket.c

@ -303,7 +303,7 @@ int32_t electrum_process_array(struct iguana_info *coin,struct electrum_info *ep
else
{
//printf("external unspent has no gettxout\n");
flag += LP_address_utxoadd((uint32_t)time(NULL),"electrum process",coin,coinaddr,txid,v,value,0,1);
flag += LP_address_utxoadd(0,(uint32_t)time(NULL),"electrum process",coin,coinaddr,txid,v,value,0,1);
}
}
else
@ -348,7 +348,7 @@ int32_t electrum_process_array(struct iguana_info *coin,struct electrum_info *ep
if ( tx->height > 0 )
{
//printf("from electrum_process_array\n");
flag += LP_address_utxoadd((uint32_t)time(NULL),"electrum process2",coin,coinaddr,txid,v,value,tx->height,-1);
flag += LP_address_utxoadd(0,(uint32_t)time(NULL),"electrum process2",coin,coinaddr,txid,v,value,tx->height,-1);
}
//printf("v.%d numvouts.%d %.8f (%s)\n",v,tx->numvouts,dstr(tx->outpoints[jint(item,"tx_pos")].value),jprint(item,0));
} //else printf("cant find tx\n");
@ -551,7 +551,7 @@ cJSON *electrum_address_gethistory(char *symbol,struct electrum_info *ep,cJSON *
if ( tx->height > 0 && tx->height != height )
printf("update %s height.%d <- %d\n",bits256_str(str,txid),tx->height,height);
tx->height = height;
LP_address_utxoadd((uint32_t)time(NULL),"electrum history",coin,addr,txid,0,0,height,-1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"electrum history",coin,addr,txid,0,0,height,-1);
}
}
}

10
iguana/exchanges/LP_transaction.c

@ -1077,7 +1077,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
if ( up == 0 )
{
value = LP_txvalue(0,coin->symbol,utxotxid,utxovout);
LP_address_utxoadd((uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1);
//printf("added after not finding\n");
}
if ( (up= LP_address_utxofind(coin,coin->smartaddr,utxotxid,utxovout)) != 0 )
@ -1085,6 +1085,12 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
else
{
printf("couldnt add address_utxo after not finding\n");
sleep(1);
value = LP_txvalue(0,coin->symbol,utxotxid,utxovout);
LP_address_utxoadd(0,(uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1);
if ( (up= LP_address_utxofind(coin,coin->smartaddr,utxotxid,utxovout)) != 0 )
preselected[numpre++] = up;
else printf("second couldnt add address_utxo after not finding\n");
//return(0);
}
}
@ -1458,7 +1464,7 @@ int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pub
rawtx->I.completed = 1;
rawtx->I.signedtxid = jbits256(retjson,"txid");
retval = 0;
} else printf("rawtx withdraw error? (%s)\n",retstr);
} else printf("rawtx withdraw error? (%s)\n",jprint(argjson,0));
free_json(retjson);
}
free(retstr);

72
iguana/exchanges/LP_utxo.c

@ -381,7 +381,7 @@ void LP_mark_spent(char *symbol,bits256 txid,int32_t vout)
}
}
int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight)
int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight)
{
struct LP_address *ap; cJSON *txobj; struct LP_transaction *tx; struct LP_address_utxo *up,*tmp; int32_t flag,retval = 0; //char str[65];
if ( coin == 0 )
@ -393,20 +393,23 @@ int32_t LP_address_utxoadd(uint32_t timestamp,char *debug,struct iguana_info *co
if ( ap != 0 )
{
flag = 0;
DL_FOREACH_SAFE(ap->utxos,up,tmp)
if ( skipsearch == 0 )
{
if ( vout == up->U.vout && bits256_cmp(up->U.txid,txid) == 0 )
DL_FOREACH_SAFE(ap->utxos,up,tmp)
{
flag = 1;
if ( height > 0 && up->U.height != height )
up->U.height = height, flag |= 2;
if ( spendheight > 0 && up->spendheight != spendheight )
up->spendheight = spendheight, flag |= 4;
if ( value != 0 && up->U.value == 0 && up->U.value != value )
up->U.value = value, flag |= 8;
//up->timestamp = timestamp;
//char str[65]; printf("found >>>>>>>>>> %s %s %s/v%d ht.%d %.8f\n",coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value));
break;
if ( vout == up->U.vout && bits256_cmp(up->U.txid,txid) == 0 )
{
flag = 1;
if ( height > 0 && up->U.height != height )
up->U.height = height, flag |= 2;
if ( spendheight > 0 && up->spendheight != spendheight )
up->spendheight = spendheight, flag |= 4;
if ( value != 0 && up->U.value == 0 && up->U.value != value )
up->U.value = value, flag |= 8;
//up->timestamp = timestamp;
//char str[65]; printf("found >>>>>>>>>> %s %s %s/v%d ht.%d %.8f\n",coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value));
break;
}
}
}
if ( flag == 0 && value != 0 )
@ -454,23 +457,23 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
printf("LP_address_utxo_reset: cant find address data\n");
return(0);
}
if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+600 )
if ( IAMLP != 0 && time(NULL) < coin->lastresetutxo+10 )
return(ap);
coin->lastresetutxo = (uint32_t)time(NULL);
portable_mutex_lock(&coin->addressutxo_mutex);
if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 )
{
//printf("clear ap->utxos\n");
printf("reset %s ap->utxos\n",coin->symbol);
portable_mutex_lock(&coin->addrmutex);
portable_mutex_lock(&LP_gcmutex);
DL_FOREACH_SAFE(ap->utxos,up,tmp)
{
portable_mutex_lock(&coin->addrmutex);
DL_DELETE(ap->utxos,up);
portable_mutex_unlock(&coin->addrmutex);
portable_mutex_lock(&LP_gcmutex);
up->spendheight = (int32_t)time(NULL);
DL_APPEND(LP_garbage_collector2,up);
portable_mutex_unlock(&LP_gcmutex);
}
//printf("done clearing ap->utxos\n");
portable_mutex_unlock(&coin->addrmutex);
portable_mutex_unlock(&LP_gcmutex);
now = (uint32_t)time(NULL);
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
@ -480,12 +483,15 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
//{"tx_hash":"38d1b7c73015e1b1d6cb7fc314cae402a635b7d7ea294970ab857df8777a66f4","tx_pos":0,"height":577975,"value":238700}
item = jitem(array,i);
value = LP_listunspent_parseitem(coin,&txid,&vout,&height,item);
if ( (txobj= LP_gettxout(coin->symbol,coin->smartaddr,txid,vout)) == 0 )
continue;
else free_json(txobj);
if ( LP_numconfirms(coin->symbol,coin->smartaddr,txid,vout,0) <= 0 )
continue;
LP_address_utxoadd(now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1);
if ( 1 )
{
if ( (txobj= LP_gettxout(coin->symbol,coin->smartaddr,txid,vout)) == 0 )
continue;
else free_json(txobj);
if ( LP_numconfirms(coin->symbol,coin->smartaddr,txid,vout,0) <= 0 )
continue;
}
LP_address_utxoadd(1,now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1);
if ( (up= LP_address_utxofind(coin,coin->smartaddr,txid,vout)) == 0 )
printf("couldnt find just added %s/%d ht.%d %.8f\n",bits256_str(str,txid),vout,height,dstr(value));
else
@ -494,10 +500,11 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
//printf("%.8f ",dstr(value));
}
}
//printf("added %d from listunspents\n",m);
printf("added %d from %s listunspents\n",m,coin->symbol);
}
free_json(array);
}
portable_mutex_unlock(&coin->addressutxo_mutex);
return(ap);
}
@ -549,9 +556,10 @@ cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrum
}
if ( up->spendheight <= 0 && up->U.value != 0 )
{
char str[65];
if ( LP_allocated(up->U.txid,up->U.vout) != 0 )
printf("%s %s/v%d allocated\n",coin->symbol,bits256_str(str,up->U.txid),up->U.vout);
{
//printf("%s %s/v%d allocated\n",coin->symbol,bits256_str(str,up->U.txid),up->U.vout);
}
else if ( coin->electrum == 0 || up->SPV > 0 )
{
jaddi(array,LP_address_item(coin,up,electrumret));
@ -732,7 +740,7 @@ int32_t LP_unspents_array(struct iguana_info *coin,char *coinaddr,cJSON *array)
if ( errs == 0 )
{
//printf("from LP_unspents_array\n");
LP_address_utxoadd((uint32_t)time(NULL),"LP_unspents_array",coin,coinaddr,txid,v,val,height,-1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_unspents_array",coin,coinaddr,txid,v,val,height,-1);
count++;
}
}
@ -796,7 +804,7 @@ cJSON *LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter,cJS
tx->outpoints[i].interest = SATOSHIDEN * jdouble(vout,"interest");
LP_destaddr(tx->outpoints[i].coinaddr,vout);
//printf("from transaction init %s %s %s/v%d <- %.8f\n",coin->symbol,tx->outpoints[i].coinaddr,bits256_str(str,txid),i,dstr(tx->outpoints[i].value));
LP_address_utxoadd((uint32_t)time(NULL),"LP_transactioninit iter0",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_transactioninit iter0",coin,tx->outpoints[i].coinaddr,txid,i,tx->outpoints[i].value,height,-1);
}
//printf("numvouts.%d\n",numvouts);
}
@ -818,7 +826,7 @@ cJSON *LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter,cJS
tx->outpoints[spentvout].spendtxid = txid;
tx->outpoints[spentvout].spendvini = i;
tx->outpoints[spentvout].spendheight = height > 0 ? height : 1;
LP_address_utxoadd((uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1);
LP_address_utxoadd(0,(uint32_t)time(NULL),"LP_transactioninit iter1",coin,tx->outpoints[spentvout].coinaddr,spenttxid,spentvout,tx->outpoints[spentvout].value,-1,height>0?height:1);
if ( 0 && strcmp(coin->symbol,"REVS") == 0 )
printf("spend %s %s/v%d at ht.%d\n",coin->symbol,bits256_str(str,tx->txid),spentvout,height);
}

2
iguana/exchanges/stats.c

@ -858,7 +858,7 @@ void stats_rpcloop(void *args)
req->port = port;
LP_rpc_processreq(req);
continue;
// this leads to cant open file errors
// this might lead to "cant open file errors"
if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 )
{
printf("error launching rpc handler on port %d, retval.%d\n",port,retval);

Loading…
Cancel
Save