Browse Source

Balances

etomic
jl777 7 years ago
parent
commit
3287f0ace2
  1. 3
      iguana/exchanges/LP_commands.c
  2. 15
      iguana/exchanges/LP_statemachine.c
  3. 49
      iguana/exchanges/LP_utxo.c
  4. 3
      iguana/exchanges/balances
  5. 2
      iguana/exchanges/install
  6. 15
      iguana/exchanges/mm.c

3
iguana/exchanges/LP_commands.c

@ -135,6 +135,7 @@ listunspent(coin, address)\n\
setconfirms(coin, numconfirms, maxconfirms=6)\n\
trust(pubkey, trust) # positive to trust, 0 for normal, negative to blacklist\n\
balance(coin, address)\n\
balances(address)\n\
orderbook(base, rel, duration=3600)\n\
getprices()\n\
getprice(base, rel)\n\
@ -256,6 +257,8 @@ instantdex_claim()\n\
return(LP_peers());
else if ( strcmp(method,"getcoins") == 0 )
return(jprint(LP_coinsjson(0),1));
else if ( strcmp(method,"balances") == 0 )
return(jprint(LP_balances(),1));
else if ( strcmp(method,"notarizations") == 0 )
{
if ( (ptr= LP_coinsearch(coin)) != 0 )

15
iguana/exchanges/LP_statemachine.c

@ -3597,6 +3597,21 @@ void LP_price_broadcastloop(void *ctx)
break;
}
return(clonestr("{\"error\":\"no instantdex deposits to claim\"}"));*/
/*else
{
if ( (array= LP_address_utxos(coin,coinaddr,1)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
balance += j64bits(item,"value");
}
}
free_json(array);
}
}*/
//else if ( strcmp(method,"checktxid") == 0 )

49
iguana/exchanges/LP_utxo.c

@ -578,9 +578,9 @@ cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrum
cJSON *LP_address_balance(struct iguana_info *coin,char *coinaddr,int32_t electrumret)
{
cJSON *array,*retjson,*item; bits256 zero; int32_t i,n; uint64_t balance = 0;
memset(zero.bytes,0,sizeof(zero));
if ( coin->electrum == 0 )
{
memset(zero.bytes,0,sizeof(zero));
if ( (array= LP_listunspent(coin->symbol,coinaddr,zero,zero)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
@ -596,23 +596,12 @@ cJSON *LP_address_balance(struct iguana_info *coin,char *coinaddr,int32_t electr
}
else
{
//if ( strcmp(coin->smartaddr,coinaddr) == 0 )
balance = LP_unspents_load(coin->symbol,coinaddr);
/*else
if ( strcmp(coin->smartaddr,coinaddr) != 0 )
{
if ( (array= LP_address_utxos(coin,coinaddr,1)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
balance += j64bits(item,"value");
}
}
free_json(array);
}
}*/
if ( (retjson= electrum_address_listunspent(coin->symbol,coin->electrum,&retjson,coinaddr,2,zero,zero)) != 0 )
free_json(retjson);
}
balance = LP_unspents_load(coin->symbol,coinaddr);
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
@ -627,6 +616,32 @@ cJSON *LP_address_balance(struct iguana_info *coin,char *coinaddr,int32_t electr
return(retjson);
}
cJSON *LP_balances()
{
struct iguana_info *coin,*tmp; char *symbol; cJSON *array,*item,*retjson;
array = cJSON_CreateArray();
HASH_ITER(hh,LP_coins,coin,tmp)
{
if ( (retjson= LP_address_balance(coin,coin->smartaddr,1)) != 0 )
{
if ( (symbol= jstr(retjson,"coin")) != 0 )
{
item = cJSON_CreateObject();
jaddstr(item,"coin",symbol);
jaddnum(item,"balance",jdouble(retjson,"balance"));
if ( strcmp(symbol,"KMD") == 0 )
{
jaddnum(item,"zcredits",jdouble(retjson,"zcredits"));
jadd(item,"zdebits",jobj(retjson,"zdebits"));
}
jaddi(array,item);
}
free_json(retjson);
}
}
return(array);
}
int32_t LP_unspents_array(struct iguana_info *coin,char *coinaddr,cJSON *array)
{
int32_t i,n,v,errs,height,count=0; uint64_t value,val; cJSON *item,*txobj; bits256 txid;

3
iguana/exchanges/balances

@ -0,0 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\"}"

2
iguana/exchanges/install

@ -1,5 +1,5 @@
#!/bin/bash
cp dynamictrust getcoin kickstart tradesarray claim deposit10 deposit1 invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts
cp balances dynamictrust getcoin kickstart tradesarray claim deposit10 deposit1 invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts
cp coins.json ..
cd ../dexscripts
#cp ../exchanges/passphrase ../exchanges/userpass .

15
iguana/exchanges/mm.c

@ -884,9 +884,18 @@ int main(int argc, const char * argv[])
{
uint8_t addrtype,rmd160[20],rmd160b[20]; char coinaddr[64],coinaddr2[64];
bitcoin_addr2rmd160(0,&addrtype,rmd160,(char *)argv[1]);
bitcoin_address(coinaddr,0,60,rmd160,20);
bitcoin_addr2rmd160(0,&addrtype,rmd160b,coinaddr);
bitcoin_address(coinaddr2,0,0,rmd160b,20);
if ( addrtype == 0 )
{
bitcoin_address(coinaddr,0,60,rmd160,20);
bitcoin_addr2rmd160(0,&addrtype,rmd160b,coinaddr);
bitcoin_address(coinaddr2,0,0,rmd160b,20);
}
else if ( addrtype == 60 )
{
bitcoin_address(coinaddr,0,0,rmd160,20);
bitcoin_addr2rmd160(0,&addrtype,rmd160b,coinaddr);
bitcoin_address(coinaddr2,0,60,rmd160b,20);
}
printf("(%s) -> %s -> %s\n",(char *)argv[1],coinaddr,coinaddr2);
if ( strcmp((char *)argv[1],coinaddr2) != 0 )
printf("ERROR\n");

Loading…
Cancel
Save