Browse Source

Test

etomic
jl777 7 years ago
parent
commit
d593f9e467
  1. 4
      iguana/exchanges/LP_prices.c
  2. 6
      iguana/exchanges/LP_signatures.c
  3. 12
      iguana/exchanges/LP_statemachine.c
  4. 25
      iguana/exchanges/LP_utxo.c

4
iguana/exchanges/LP_prices.c

@ -99,9 +99,9 @@ void LP_pubkey_update(struct LP_pubkey_info *pubp,uint32_t baseind,uint32_t reli
pq->relind = relind; pq->relind = relind;
pq->scale = 6; // millions of SATOSHIS, ie. 0.01 pq->scale = 6; // millions of SATOSHIS, ie. 0.01
DL_APPEND(pubp->quotes,pq); // already serialized as only path is via stats_JSON() DL_APPEND(pubp->quotes,pq); // already serialized as only path is via stats_JSON()
printf("create pubp quotes %d/%d\n",baseind,relind); //printf("create pubp quotes %d/%d\n",baseind,relind);
} }
printf("%d/%d price %.8f balance %.8f %s num.%d %.8f %.8f\n",baseind,relind,price,dstr(balance),utxocoin,numutxos,dstr(minutxo),dstr(maxutxo)); //printf("%d/%d price %.8f balance %.8f %s num.%d %.8f %.8f\n",baseind,relind,price,dstr(balance),utxocoin,numutxos,dstr(minutxo),dstr(maxutxo));
pq->price = price; pq->price = price;
if ( utxocoin != 0 && utxocoin[0] != 0 ) if ( utxocoin != 0 && utxocoin[0] != 0 )
{ {

6
iguana/exchanges/LP_signatures.c

@ -451,7 +451,7 @@ int32_t LP_price_sigadd(cJSON *item,uint32_t timestamp,bits256 priv,uint8_t *pub
char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price) char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price)
{ {
struct iguana_info *basecoin,*relcoin; struct LP_address *ap; char pubsecpstr[67]; uint32_t numutxos,timestamp; uint64_t price64,balance,minsize,maxsize; bits256 zero; cJSON *reqjson; struct iguana_info *basecoin,*relcoin; char pubsecpstr[67]; uint32_t numutxos,timestamp; uint64_t price64,balance,minsize,maxsize; bits256 zero; cJSON *reqjson;
reqjson = cJSON_CreateObject(); reqjson = cJSON_CreateObject();
// LP_addsig // LP_addsig
if ( (basecoin= LP_coinfind(base)) != 0 && (relcoin= LP_coinfind(rel)) != 0 )//&& basecoin->electrum == 0 )//&& relcoin->electrum == 0 ) if ( (basecoin= LP_coinfind(base)) != 0 && (relcoin= LP_coinfind(rel)) != 0 )//&& basecoin->electrum == 0 )//&& relcoin->electrum == 0 )
@ -468,9 +468,9 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re
jaddnum(reqjson,"timestamp",timestamp); jaddnum(reqjson,"timestamp",timestamp);
init_hexbytes_noT(pubsecpstr,G.LP_pubsecp,33); init_hexbytes_noT(pubsecpstr,G.LP_pubsecp,33);
jaddstr(reqjson,"pubsecp",pubsecpstr); jaddstr(reqjson,"pubsecp",pubsecpstr);
if ( (ap= LP_address(basecoin,basecoin->smartaddr)) != 0 ) //if ( (ap= LP_address(basecoin,basecoin->smartaddr)) != 0 )
{ {
if ( (numutxos= LP_address_minmax(&balance,&minsize,&maxsize,ap)) != 0 ) if ( (numutxos= LP_address_minmax(&balance,&minsize,&maxsize,basecoin,basecoin->smartaddr)) != 0 )
{ {
printf("send %s numutxos.%d balance %.8f min %.8f max %.8f\n",base,numutxos,dstr(balance),dstr(minsize),dstr(maxsize)); printf("send %s numutxos.%d balance %.8f min %.8f max %.8f\n",base,numutxos,dstr(balance),dstr(minsize),dstr(maxsize));
jaddstr(reqjson,"utxocoin",base); jaddstr(reqjson,"utxocoin",base);

12
iguana/exchanges/LP_statemachine.c

@ -3238,6 +3238,18 @@ while ( 1 )
} }
return(clonestr("{\"error\":\"cant get here\"}")); return(clonestr("{\"error\":\"cant get here\"}"));
#endif #endif
/*DL_FOREACH_SAFE(ap->utxos,up,tmp)
{
if ( up->spendheight <= 0 )
{
if ( up->U.value > *maxp )
*maxp = up->U.value;
if ( *minp == 0 || up->U.value < *minp )
*minp = up->U.value;
*balancep += up->U.value;
n++;
}
}*/
char *LP_ordermatch(char *base,int64_t txfee,double maxprice,double maxvolume,char *rel,bits256 txid,int32_t vout,bits256 feetxid,int32_t feevout,int64_t desttxfee,int32_t duration) char *LP_ordermatch(char *base,int64_t txfee,double maxprice,double maxvolume,char *rel,bits256 txid,int32_t vout,bits256 feetxid,int32_t feevout,int64_t desttxfee,int32_t duration)
{ {

25
iguana/exchanges/LP_utxo.c

@ -238,24 +238,27 @@ struct LP_address *LP_address(struct iguana_info *coin,char *coinaddr)
return(ap); return(ap);
} }
int32_t LP_address_minmax(uint64_t *balancep,uint64_t *minp,uint64_t *maxp,struct LP_address *ap) int32_t LP_address_minmax(uint64_t *balancep,uint64_t *minp,uint64_t *maxp,struct iguana_info *coin,char *coinaddr)
{ {
struct LP_address_utxo *up,*tmp; int32_t n = 0; cJSON *array,*item; bits256 txid; int64_t value; int32_t i,vout,height,n = 0;
*minp = *maxp = *balancep = 0; *minp = *maxp = *balancep = 0;
DL_FOREACH_SAFE(ap->utxos,up,tmp) if ( (array= LP_listunspent(coin->symbol,coinaddr)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{ {
if ( up->spendheight <= 0 ) for (i=0; i<n; i++)
{ {
if ( up->U.value > *maxp ) item = jitem(array,i);
*maxp = up->U.value; value = LP_listunspent_parseitem(coin,&txid,&vout,&height,item);
if ( *minp == 0 || up->U.value < *minp ) if ( value > *maxp )
*minp = up->U.value; *maxp = value;
*balancep += up->U.value; if ( *minp == 0 || value < *minp )
*minp = value;
*balancep += value;
n++; n++;
} }
} }
if ( 0 && n > 0 ) }
printf("n.%d %s min %.8f max %.8f\n",n,ap->coinaddr,dstr(*minp),dstr(*maxp));
return(n); return(n);
} }

Loading…
Cancel
Save