Browse Source

Test

etomic
jl777 7 years ago
parent
commit
520e5bbf83
  1. 43
      iguana/exchanges/LP_commands.c
  2. 1
      iguana/exchanges/LP_include.h
  3. 11
      iguana/exchanges/LP_ordermatch.c
  4. 2
      iguana/exchanges/LP_prices.c

43
iguana/exchanges/LP_commands.c

@ -363,7 +363,7 @@ dividends(coin, height, <args>)\n\
coinaddr = jstr(argjson,"coinaddr");
if ( coin != 0 && coinaddr != 0 )
{
//char str[65]; printf("uitem %s %s %s/v%d %.8f ht.%d\n",coin,coinaddr,bits256_str(str,txid),vout,dstr(value),height);
char str[65]; printf("uitem %s %s %s/v%d %.8f ht.%d\n",coin,coinaddr,bits256_str(str,txid),vout,dstr(value),height);
LP_address_utxoadd(LP_coinfind(coin),coinaddr,txid,vout,value,height,-1);
}
return(clonestr("{\"result\":\"success\"}"));
@ -416,6 +416,47 @@ dividends(coin, height, <args>)\n\
}
else if ( strcmp(method,"checktxid") == 0 )
retstr = LP_spentcheck(argjson);
else if ( strcmp(method,"addr_unspents") == 0 )
{
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;
if ( (coinaddr= jstr(argjson,"address")) != 0 )
{
if ( coinaddr[0] != 0 )
{
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; i<n; i++)
{
item = jitem(array,i);
txid = jbits256(item,"txid");
vout = jint(item,"vout");
height = jint(item,"height");
value = j64bits(item,"value");
req = cJSON_CreateObject();
jaddstr(req,"method","uitem");
jaddstr(req,"coinaddr",coinaddr);
jaddbits256(req,"txid",txid);
jaddnum(req,"vout",vout);
jaddnum(req,"ht",height);
jadd64bits(req,"value",value);
LP_broadcast_message(pubsock,"","",zero,jprint(reqjson,1));
}
}
free_json(array);
}
}
}
}
}
}
else if ( strcmp(method,"getcoins") == 0 )
return(jprint(LP_coinsjson(0),1));
else if ( strcmp(method,"numutxos") == 0 )

1
iguana/exchanges/LP_include.h

@ -326,5 +326,6 @@ double LP_getestimatedrate(struct iguana_info *coin);
struct LP_utxoinfo *_LP_utxofind(int32_t iambob,bits256 txid,int32_t vout);
struct LP_utxoinfo *_LP_utxo2find(int32_t iambob,bits256 txid,int32_t vout);
void LP_listunspent_query(char *symbol,char *coinaddr);
#endif

11
iguana/exchanges/LP_ordermatch.c

@ -244,6 +244,17 @@ void LP_notify_pubkeys(void *ctx,int32_t pubsock)
LP_broadcast_message(pubsock,"","",zero,msg);
}
void LP_listunspent_query(char *symbol,char *coinaddr)
{
bits256 zero; char *msg; cJSON *reqjson = cJSON_CreateObject();
memset(zero.bytes,0,sizeof(zero));
jaddstr(reqjson,"method","addr_unspents");
jaddstr(reqjson,"coin",symbol);
jaddstr(reqjson,"address",coinaddr);
msg = jprint(reqjson,1);
LP_broadcast_message(LP_mypubsock,"","",zero,msg);
}
char *LP_postedprice(cJSON *argjson)
{
bits256 pubkey; double price; char *base,*rel;

2
iguana/exchanges/LP_prices.c

@ -776,6 +776,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_query(rel,bids[i]->coinaddr);
n++;
}
free(bids[i]);
@ -794,6 +795,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_query(base,asks[i]->coinaddr);
n++;
}
free(asks[i]);

Loading…
Cancel
Save