diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index a74d55e22..583b1096d 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -421,7 +421,7 @@ dividends(coin, height, )\n\ printf("GOT ADDR_UNSPENTS\n"); if ( (ptr= LP_coinsearch(jstr(argjson,"coin"))) != 0 ) { - char *coinaddr; cJSON *array,*item,*req; int32_t i,n,vout,height; bits256 zero,txid; uint64_t value; + char *coinaddr; //cJSON *array,*item,*req; int32_t i,n,vout,height; bits256 zero,txid; uint64_t value; if ( (coinaddr= jstr(argjson,"address")) != 0 ) { if ( coinaddr[0] != 0 ) @@ -429,32 +429,7 @@ dividends(coin, height, )\n\ if ( strcmp(coinaddr,ptr->smartaddr) == 0 && bits256_nonz(G.LP_mypriv25519) != 0 ) { printf("%s %s is my address being asked for!\n",ptr->symbol,coinaddr); - if ( (array= LP_address_utxos(ptr,coinaddr,1)) != 0 ) - { - memset(zero.bytes,0,sizeof(zero)); - if ( (n= cJSON_GetArraySize(array)) > 0 ) - { - for (i=0; isymbol); - jaddstr(req,"coinaddr",coinaddr); - jaddbits256(req,"txid",txid); - jaddnum(req,"vout",vout); - jaddnum(req,"ht",height); - jadd64bits(req,"value",value); - printf("ADDR_UNSPENTS[] <- %s\n",jprint(req,0)); - LP_broadcast_message(pubsock,"","",zero,jprint(req,1)); - } - } - free_json(array); - } + ptr->addr_listunspent_requested = (uint32_t)time(NULL); } } } diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 3cc60f12f..c3ee027af 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -183,7 +183,7 @@ struct iguana_info portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses; uint64_t txfee; int32_t longestchain,firstrefht,firstscanht,lastscanht,bussock,height; uint16_t busport; - uint32_t lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,unspenttime,obooktime; + uint32_t addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,unspenttime,obooktime; uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag; char symbol[16],smartaddr[64],userpass[1024],serverport[128],lastunspent[64]; // portfolio diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 2b7d1a6fe..4d294fc9c 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -320,11 +320,12 @@ void command_rpcloop(void *myipaddr) void LP_smartutxos_push(struct iguana_info *coin) { - struct LP_peerinfo *peer,*tmp; uint64_t value; bits256 txid; int32_t i,vout,height,n; char *retstr; cJSON *array,*item; + struct LP_peerinfo *peer,*tmp; uint64_t value; bits256 zero,txid; int32_t i,vout,height,n; char *retstr; cJSON *array,*item,*req; if ( coin->smartaddr[0] == 0 ) return; if ( (array= LP_address_utxos(coin,coin->smartaddr,1)) != 0 ) { + memset(zero.bytes,0,sizeof(zero)); if ( (n= cJSON_GetArraySize(array)) > 0 ) { printf("PUSH %s %s\n",coin->symbol,coin->smartaddr); @@ -335,11 +336,27 @@ void LP_smartutxos_push(struct iguana_info *coin) vout = jint(item,"tx_pos"); value = j64bits(item,"value"); height = jint(item,"height"); + if ( 0 ) + { HASH_ITER(hh,LP_peerinfos,peer,tmp) { if ( (retstr= issue_LP_uitem(peer->ipaddr,peer->port,coin->symbol,coin->smartaddr,txid,vout,height,value)) != 0 ) free(retstr); } + } + else + { + req = cJSON_CreateObject(); + jaddstr(req,"method","uitem"); + jaddstr(req,"coin",coin->symbol); + jaddstr(req,"coinaddr",coin->smartaddr); + jaddbits256(req,"txid",txid); + jaddnum(req,"vout",vout); + jaddnum(req,"ht",height); + jadd64bits(req,"value",value); + printf("ADDR_UNSPENTS[] <- %s\n",jprint(req,0)); + LP_broadcast_message(LP_mypubsock,"","",zero,jprint(req,1)); + } } } free_json(array); @@ -532,13 +549,14 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int HASH_ITER(hh,LP_coins,coin,ctmp) // firstrefht,firstscanht,lastscanht { memset(&zero,0,sizeof(zero)); - if ( coin->inactive != 0 ) - continue; - /*if ( (counter % 6000) == 100 ) + if ( coin->addr_listunspent_requested != 0 ) { + printf("addr_listunspent_requested %u\n",coin->addr_listunspent_requested); LP_smartutxos_push(coin); - nonz++; - }*/ + coin->addr_listunspent_requested = 0; + } + if ( coin->inactive != 0 ) + continue; if ( coin->electrum != 0 ) continue; //if ( coin->obooktime == 0 ) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 247281d52..d5fef89a5 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -957,7 +957,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q struct LP_utxoinfo *LP_buyutxo(double *ordermatchpricep,int64_t *bestsatoshisp,int64_t *bestdestsatoshisp,struct LP_utxoinfo *autxo,char *base,double maxprice,int32_t duration,uint64_t txfee,uint64_t desttxfee,char *gui,bits256 *avoids,int32_t numavoids) { - bits256 pubkey; char *obookstr,coinaddr[64],str[65]; cJSON *orderbook,*asks,*item; int32_t i,j,n,numasks,max = 10000; struct LP_address_utxo **utxos; double price; struct LP_pubkeyinfo *pubp; struct iguana_info *basecoin; uint64_t basesatoshis; struct LP_utxoinfo *bestutxo = 0; + bits256 pubkey; char *obookstr,coinaddr[64]; cJSON *orderbook,*asks,*item; int32_t i,j,n,numasks,max = 10000; struct LP_address_utxo **utxos; double price; struct LP_pubkeyinfo *pubp; struct iguana_info *basecoin; uint64_t basesatoshis; struct LP_utxoinfo *bestutxo = 0; *ordermatchpricep = 0.; *bestsatoshisp = *bestdestsatoshisp = 0; basecoin = LP_coinfind(base); diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index d4a9c1912..5e6dc9105 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -440,7 +440,7 @@ cJSON *LP_listunspent(char *symbol,char *coinaddr) int32_t LP_listunspent_issue(char *symbol,char *coinaddr) { - struct iguana_info *coin; int32_t n = 0; cJSON *retjson=0; char *retstr=0,destip[64]; uint16_t destport; + struct iguana_info *coin; int32_t n = 0; cJSON *retjson=0; char *retstr=0;// uint16_t destport; if ( symbol == 0 || symbol[0] == 0 ) return(0); if ( (coin= LP_coinfind(symbol)) != 0 )