From a1821d977e3e4ef5f6a83f3c34f0c60da0011afc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 14 Oct 2017 14:07:37 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_commands.c | 2 +- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_nativeDEX.c | 2 +- iguana/exchanges/LP_ordermatch.c | 10 +++++----- iguana/exchanges/LP_prices.c | 6 +++--- iguana/exchanges/LP_rpc.c | 15 +++++++++------ iguana/exchanges/LP_scan.c | 2 +- iguana/exchanges/LP_utxo.c | 2 +- iguana/exchanges/LP_utxos.c | 6 +++--- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index bb2fb1c4c..8acc60b7c 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -379,7 +379,7 @@ dividends(coin, height, )\n\ { if ( coinaddr[0] != 0 ) { - LP_listunspent_issue(coin,coinaddr); + LP_listunspent_issue(coin,coinaddr,1); if ( strcmp(coinaddr,ptr->smartaddr) == 0 && bits256_nonz(G.LP_mypriv25519) != 0 ) { LP_privkey_init(-1,ptr,G.LP_mypriv25519,G.LP_mypub25519); diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index c3ee027af..cda18e7f7 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -316,7 +316,7 @@ void LP_smartutxos_push(struct iguana_info *coin); cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrumret); cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout); void LP_postutxos(char *symbol,char *coinaddr); -int32_t LP_listunspent_both(char *symbol,char *coinaddr); +int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag); uint16_t LP_randpeer(char *destip); cJSON *bitcoin_data2json(uint8_t taddr,uint8_t pubtype,uint8_t p2shtype,uint8_t isPoS,int32_t height,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len,cJSON *vins,int32_t suppress_pubkeys); //int32_t LP_butxo_findeither(bits256 txid,int32_t vout); diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 655cdb012..e5686e5a3 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -375,7 +375,7 @@ int32_t LP_utxos_sync(struct LP_peerinfo *peer) if ( coin->smartaddr[0] == 0 ) continue; total = 0; - if ( (j= LP_listunspent_both(coin->symbol,coin->smartaddr)) == 0 ) + if ( (j= LP_listunspent_both(coin->symbol,coin->smartaddr,0)) == 0 ) continue; if ( (array= LP_address_utxos(coin,coin->smartaddr,1)) != 0 ) { diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index e6e89bc05..d12d66312 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -252,7 +252,7 @@ void LP_listunspent_query(char *symbol,char *coinaddr) jaddstr(reqjson,"coin",symbol); jaddstr(reqjson,"address",coinaddr); msg = jprint(reqjson,1); - printf("BROADCAST.(%s)\n",msg); + //printf("BROADCAST.(%s)\n",msg); LP_broadcast_message(LP_mypubsock,"","",zero,msg); } @@ -733,7 +733,7 @@ char *LP_connectedalice(cJSON *argjson) // alice } } -int32_t LP_listunspent_both(char *symbol,char *coinaddr) +int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag) { int32_t i,v,height,n=0; uint64_t value; bits256 txid; char buf[512]; cJSON *array,*item; struct iguana_info *coin = LP_coinfind(symbol); if ( coin != 0 )//&& (IAMLP != 0 || coin->inactive == 0) ) @@ -743,7 +743,7 @@ int32_t LP_listunspent_both(char *symbol,char *coinaddr) //printf("issue path electrum.%p\n",coin->electrum); //if ( coin->electrum != 0 && (array= electrum_address_gethistory(symbol,coin->electrum,&array,coinaddr)) != 0 ) // free_json(array); - n = LP_listunspent_issue(symbol,coinaddr); + n = LP_listunspent_issue(symbol,coinaddr,fullflag); } else { @@ -799,7 +799,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, if ( LP_allocated(butxo->payment.txid,butxo->payment.vout) != 0 || LP_allocated(butxo->deposit.txid,butxo->deposit.vout) != 0 || (qprice= LP_quote_validate(autxo,butxo,&Q,1)) <= SMALLVAL ) { printf("butxo.%p replace path %p %s, %p %s, %.8f\n",butxo,LP_allocated(butxo->payment.txid,butxo->payment.vout),bits256_str(str,butxo->payment.txid),LP_allocated(butxo->deposit.txid,butxo->deposit.vout),bits256_str(str2,butxo->deposit.txid),LP_quote_validate(autxo,butxo,&Q,1)); - LP_listunspent_both(Q.srccoin,Q.coinaddr); + LP_listunspent_both(Q.srccoin,Q.coinaddr,0); if ( (butxo= LP_address_utxopair(1,utxos,max,LP_coinfind(Q.srccoin),Q.coinaddr,Q.txfee,dstr(Q.destsatoshis),price,Q.desttxfee)) != 0 ) { Q.txid = butxo->payment.txid; @@ -1009,7 +1009,7 @@ struct LP_utxoinfo *LP_buyutxo(double *ordermatchpricep,int64_t *bestsatoshisp,i { bitcoin_address(coinaddr,basecoin->taddr,basecoin->pubtype,pubp->rmd160,sizeof(pubp->rmd160)); LP_listunspent_query(base,coinaddr); - LP_listunspent_both(base,coinaddr); + LP_listunspent_both(base,coinaddr,1); asatoshis = autxo->S.satoshis; for (j=0; jsymbol,coinaddr); + LP_listunspent_both(coin->symbol,coinaddr,0); if ( (array= LP_address_utxos(coin,coinaddr,1)) != 0 ) { total = 0; @@ -775,7 +775,7 @@ char *LP_orderbook(char *base,char *rel,int32_t duration) { LP_address(relcoin,bids[i]->coinaddr); if ( relcoin->electrum == 0 ) - LP_listunspent_issue(rel,bids[i]->coinaddr); + LP_listunspent_issue(rel,bids[i]->coinaddr,0); LP_listunspent_query(rel,bids[i]->coinaddr); n++; } @@ -794,7 +794,7 @@ char *LP_orderbook(char *base,char *rel,int32_t duration) { LP_address(basecoin,asks[i]->coinaddr); if ( basecoin->electrum == 0 ) - LP_listunspent_issue(base,asks[i]->coinaddr); + LP_listunspent_issue(base,asks[i]->coinaddr,0); LP_listunspent_query(base,asks[i]->coinaddr); n++; } diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index c79e0fde8..1ebceefeb 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -438,7 +438,7 @@ cJSON *LP_listunspent(char *symbol,char *coinaddr) } else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr,1)); } -int32_t LP_listunspent_issue(char *symbol,char *coinaddr) +int32_t LP_listunspent_issue(char *symbol,char *coinaddr,int32_t fullflag) { struct iguana_info *coin; int32_t n = 0; cJSON *retjson=0; char *retstr=0,destip[64]; uint16_t destport; if ( symbol == 0 || symbol[0] == 0 ) @@ -463,12 +463,15 @@ int32_t LP_listunspent_issue(char *symbol,char *coinaddr) else if ( IAMLP == 0 ) { LP_listunspent_query(coin->symbol,coin->smartaddr); - if ( (destport= LP_randpeer(destip)) > 0 ) + if ( fullflag != 0 ) { - retstr = issue_LP_listunspent(destip,destport,symbol,coinaddr); - printf("issue %s %s %s -> (%s)\n",coin->symbol,coinaddr,destip,retstr); - retjson = cJSON_Parse(retstr); - } else printf("LP_listunspent_issue couldnt get a random peer?\n"); + if ( (destport= LP_randpeer(destip)) > 0 ) + { + retstr = issue_LP_listunspent(destip,destport,symbol,coinaddr); + printf("issue %s %s %s -> (%s)\n",coin->symbol,coinaddr,destip,retstr); + retjson = cJSON_Parse(retstr); + } else printf("LP_listunspent_issue couldnt get a random peer?\n"); + } } if ( retjson != 0 ) { diff --git a/iguana/exchanges/LP_scan.c b/iguana/exchanges/LP_scan.c index 23e76098e..eb721e2ee 100644 --- a/iguana/exchanges/LP_scan.c +++ b/iguana/exchanges/LP_scan.c @@ -481,7 +481,7 @@ int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int } free(array); } - LP_listunspent_issue(coin->symbol,coinaddr); + LP_listunspent_issue(coin->symbol,coinaddr,1); struct LP_address_utxo *up; if ( (up= LP_address_utxofind(coin,coinaddr,txid,vout)) != 0 ) { diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 17e260145..d15ae08b1 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -722,7 +722,7 @@ int32_t LP_numconfirms(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int } else { - LP_listunspent_issue(symbol,coinaddr); + LP_listunspent_issue(symbol,coinaddr,1); if ( (ht= LP_txheight(coin,txid)) > 0 && ht <= coin->height ) numconfirms = (LP_getheight(coin) - ht + 1); else if ( mempool != 0 ) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 499f6bff1..376158308 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -452,7 +452,7 @@ cJSON *LP_inventory(char *symbol) if ( (coin= LP_coinfind(symbol)) != 0 ) { coin->unspenttime = (uint32_t)time(NULL) - 777; - LP_listunspent_both(symbol,coin->smartaddr); + LP_listunspent_both(symbol,coin->smartaddr,0); } HASH_ITER(hh,G.LP_utxoinfos[iambob],utxo,tmp) { @@ -519,7 +519,7 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri } //printf("privkey init.(%s) %s\n",coin->symbol,coin->smartaddr); if ( coin->inactive == 0 ) - LP_listunspent_issue(coin->symbol,coin->smartaddr); + LP_listunspent_issue(coin->symbol,coin->smartaddr,0); if ( coin->inactive == 0 && (array= LP_listunspent(coin->symbol,coin->smartaddr)) != 0 ) { txfee = LP_txfeecalc(coin,0); @@ -746,7 +746,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } if ( coin->electrum == 0 && coin->userpass[0] != 0 ) { - LP_listunspent_issue(coin->symbol,coin->smartaddr); + LP_listunspent_issue(coin->symbol,coin->smartaddr,0); if ( (retjson= LP_importprivkey(coin->symbol,tmpstr,coin->smartaddr,-1)) != 0 ) { if ( jobj(retjson,"error") != 0 )