Browse Source

Test

etomic
jl777 7 years ago
parent
commit
ea267466e9
  1. 52
      iguana/exchanges/LP_ordermatch.c
  2. 2
      iguana/exchanges/LP_prices.c
  3. 51
      iguana/exchanges/LP_statemachine.c

52
iguana/exchanges/LP_ordermatch.c

@ -683,58 +683,6 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
}
}
int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag)
{
int32_t i,v,numconfs,height,n=0; uint64_t value; bits256 txid; char buf[512]; cJSON *array,*item; uint32_t now; struct iguana_info *coin = LP_coinfind(symbol);
if ( coin != 0 )//&& (IAMLP != 0 || coin->inactive == 0) )
{
if ( coin->electrum != 0 || LP_address_ismine(symbol,coinaddr) <= 0 )
{
//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,fullflag);
}
else
{
if ( strcmp(symbol,"BTC") == 0 )
numconfs = 0;
else numconfs = 1;
//printf("my coin electrum.%p\n",coin->electrum);
sprintf(buf,"[%d, 99999999, [\"%s\"]]",numconfs,coinaddr);
if ( (array= bitcoin_json(coin,"listunspent",buf)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
now = (uint32_t)time(NULL);
for (i=0; i<n; i++)
{
item = jitem(array,i);
txid = jbits256(item,"txid");
v = jint(item,"vout");
value = LP_value_extract(item,0);
height = LP_txheight(coin,txid);
//char str[65]; printf("LP_listunspent_both: %s/v%d ht.%d %.8f\n",bits256_str(str,txid),v,height,dstr(value));
LP_address_utxoadd(now,"LP_listunspent_both",coin,coinaddr,txid,v,value,height,-1);
}
}
free_json(array);
}
}
} //else printf("%s coin.%p inactive.%d\n",symbol,coin,coin!=0?coin->inactive:-1);
return(n);
}
/*char *LP_bestfit(char *rel,double relvolume)
{
struct LP_utxoinfo *autxo;
if ( relvolume <= 0. || LP_priceinfofind(rel) == 0 )
return(clonestr("{\"error\":\"invalid parameter\"}"));
if ( (autxo= LP_utxo_bestfit(rel,SATOSHIDEN * relvolume)) == 0 )
return(clonestr("{\"error\":\"cant find utxo that is close enough in size\"}"));
return(jprint(LP_utxojson(autxo),1));
}*/
int32_t LP_aliceonly(char *symbol)
{
if ( strcmp(symbol,"GAME") == 0 )

2
iguana/exchanges/LP_prices.c

@ -338,7 +338,7 @@ char *LP_pubkey_trusted()
int64_t LP_unspents_metric(struct iguana_info *coin,char *coinaddr)
{
cJSON *array,*item; int32_t i,n; int64_t metric=0,total;
LP_listunspent_both(coin->symbol,coinaddr,0);
//LP_listunspent_both(coin->symbol,coinaddr,0);
if ( (array= LP_address_utxos(coin,coinaddr,1)) != 0 )
{
total = 0;

51
iguana/exchanges/LP_statemachine.c

@ -479,7 +479,56 @@ void issue_LP_listunspent(char *destip,uint16_t destport,char *symbol,char *coin
return(retstr);*/
}
int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag)
{
int32_t i,v,numconfs,height,n=0; uint64_t value; bits256 txid; char buf[512]; cJSON *array,*item; uint32_t now; struct iguana_info *coin = LP_coinfind(symbol);
if ( coin != 0 )//&& (IAMLP != 0 || coin->inactive == 0) )
{
if ( coin->electrum != 0 || LP_address_ismine(symbol,coinaddr) <= 0 )
{
//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,fullflag);
}
else
{
if ( strcmp(symbol,"BTC") == 0 )
numconfs = 0;
else numconfs = 1;
//printf("my coin electrum.%p\n",coin->electrum);
sprintf(buf,"[%d, 99999999, [\"%s\"]]",numconfs,coinaddr);
if ( (array= bitcoin_json(coin,"listunspent",buf)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
now = (uint32_t)time(NULL);
for (i=0; i<n; i++)
{
item = jitem(array,i);
txid = jbits256(item,"txid");
v = jint(item,"vout");
value = LP_value_extract(item,0);
height = LP_txheight(coin,txid);
//char str[65]; printf("LP_listunspent_both: %s/v%d ht.%d %.8f\n",bits256_str(str,txid),v,height,dstr(value));
LP_address_utxoadd(now,"LP_listunspent_both",coin,coinaddr,txid,v,value,height,-1);
}
}
free_json(array);
}
}
} //else printf("%s coin.%p inactive.%d\n",symbol,coin,coin!=0?coin->inactive:-1);
return(n);
}
char *LP_bestfit(char *rel,double relvolume)
{
struct LP_utxoinfo *autxo;
if ( relvolume <= 0. || LP_priceinfofind(rel) == 0 )
return(clonestr("{\"error\":\"invalid parameter\"}"));
if ( (autxo= LP_utxo_bestfit(rel,SATOSHIDEN * relvolume)) == 0 )
return(clonestr("{\"error\":\"cant find utxo that is close enough in size\"}"));
return(jprint(LP_utxojson(autxo),1));
}
int32_t LP_utxos_sync(struct LP_peerinfo *peer)
{
int32_t i,j,n=0,m,v,posted=0; bits256 txid; cJSON *array,*item,*item2,*array2; uint64_t total,total2; struct iguana_info *coin,*ctmp; char *retstr,*retstr2;

Loading…
Cancel
Save