Browse Source

Test

etomic
jl777 7 years ago
parent
commit
3d6b3f14b3
  1. 8
      iguana/exchanges/LP_commands.c
  2. 4
      iguana/exchanges/LP_include.h
  3. 4
      iguana/exchanges/LP_nativeDEX.c
  4. 24
      iguana/exchanges/LP_socket.c
  5. 14
      iguana/exchanges/LP_zeroconf.c

8
iguana/exchanges/LP_commands.c

@ -293,23 +293,23 @@ zeroconf_claim(address, expiration=0)\n\
return(basilisk_swapentries(base,rel,jint(argjson,"limit")));
else return(basilisk_swaplist(0,0));
}
/*else if ( strcmp(method,"dynamictrust") == 0 )
else if ( strcmp(method,"dynamictrust") == 0 )
{
struct LP_address *ap; char *coinaddr;
if ( (ptr= LP_coinsearch("KMD")) != 0 && (coinaddr= jstr(argjson,"address")) != 0 )
{
LP_zeroconf_deposits(ptr);
//LP_zeroconf_deposits(ptr);
if ( (ap= LP_addressfind(ptr,coinaddr)) != 0 )
{
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddstr(retjson,"address",coinaddr);
jaddnum(retjson,"zcredits",dstr(ap->zeroconf_credits));
jaddnum(retjson,"zcredits",dstr(ap->instantdex_credits));
return(jprint(retjson,1));
}
}
return(clonestr("{\"error\":\"cant find address\"}"));
}*/
}
else if ( (retstr= LP_istradebots_command(ctx,pubsock,method,argjson)) != 0 )
return(retstr);
if ( base[0] != 0 && rel[0] != 0 )

4
iguana/exchanges/LP_include.h

@ -328,7 +328,7 @@ struct LP_address
UT_hash_handle hh;
struct LP_address_utxo *utxos;
bits256 pubkey;
int64_t balance,total,zeroconf_credits;
int64_t balance,total,instantdex_credits;
uint32_t timestamp,n,unspenttime;
int32_t unspentheight;
char coinaddr[40];
@ -404,7 +404,7 @@ struct LP_pubkey_info
bits256 pubkey;
struct LP_pubkey_quote *quotes;
struct LP_pubswap *bobswaps,*aliceswaps;
uint64_t dynamictrust;
int64_t dynamictrust,unconfdeposits;
uint32_t timestamp,numerrors,lasttime,slowresponse;
int32_t istrusted;
uint8_t rmd160[20],sig[65],pubsecp[33],siglen;

4
iguana/exchanges/LP_nativeDEX.c

@ -539,11 +539,11 @@ void LP_coinsloop(void *_coins)
coin->longestchain = LP_getheight(coin);
if ( (ep= coin->electrum) != 0 )
{
if ( strcmp("KMD",coin->symbol) == 0 && coin->electrumzeroconf == 0 )
/*if ( strcmp("KMD",coin->symbol) == 0 && coin->electrumzeroconf == 0 )
{
LP_zeroconf_deposits(coin);
coin->electrumzeroconf = (uint32_t)time(NULL);
}
}*/
if ( (backupep= ep->prev) == 0 )
backupep = ep;
if ( (retjson= electrum_address_listunspent(coin->symbol,ep,&retjson,coin->smartaddr,1,zero,zero)) != 0 )

24
iguana/exchanges/LP_socket.c

@ -1045,13 +1045,33 @@ void LP_dedicatedloop(void *arg)
cJSON *LP_electrumserver(struct iguana_info *coin,char *ipaddr,uint16_t port)
{
struct electrum_info *ep; int32_t kickval,already; cJSON *retjson;
struct electrum_info *ep,*prev; int32_t kickval,already; cJSON *retjson,*array,*item;
if ( ipaddr == 0 || ipaddr[0] == 0 || port == 0 )
{
ep = coin->electrum;
coin->electrum = 0;
coin->inactive = (uint32_t)time(NULL);
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddstr(retjson,"status","electrum mode disabled, now in disabled native coin mode");
if ( ep != 0 )
{
array = cJSON_CreateArray();
while ( ep != 0 )
{
item = cJSON_CreateObject();
jaddstr(item,"ipaddr",ep->ipaddr);
jaddnum(item,"port",ep->port);
jaddnum(item,"kickstart",electrum_kickstart(ep));
jaddi(array,item);
prev = ep->prev;
ep->prev = 0;
ep = prev;
}
jadd(retjson,"electrums",array);
}
//printf("would have disabled %s electrum here\n",coin->symbol);
return(cJSON_Parse("{\"result\":\"success\",\"status\":\"electrum mode disabled, now in native coin mode\"}"));
return(cJSON_Parse("{\"result\":\"success\",\"status\":\"electrum mode disabled, now in disabled native coin mode\"}"));
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"ipaddr",ipaddr);

14
iguana/exchanges/LP_zeroconf.c

@ -201,9 +201,9 @@ void LP_zeroconf_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,int32_t
timestamp = LP_FIRSTWEEKTIME + weeki*LP_WEEKMULT;
if ( time(NULL) < timestamp-60*3600 && (ap= LP_address(coin,coinaddr)) != 0 )
{
ap->zeroconf_credits += satoshis;
ap->instantdex_credits += satoshis;
if ( dispflag != 0 )
printf("InstantDEX credit.(%s) %.8f weeki.%d (%s) -> sum %.8f\n",coinaddr,dstr(satoshis),weeki,p2shaddr,dstr(ap->zeroconf_credits));
printf("InstantDEX credit.(%s) %.8f weeki.%d (%s) -> sum %.8f\n",coinaddr,dstr(satoshis),weeki,p2shaddr,dstr(ap->instantdex_credits));
}
}
}
@ -238,12 +238,12 @@ int64_t LP_zeroconf_creditcalc(struct iguana_info *coin,int32_t dispflag,bits256
void LP_zeroconf_deposits(struct iguana_info *coin)
{
static int dispflag = 1;
cJSON *array,*item; int32_t i,n,height,vout; bits256 txid; struct LP_address *ap,*tmp;
if ( coin->electrum != 0 && coin->electrumzeroconf != 0 )
cJSON *array,*item; int32_t i,n,height,vout; bits256 txid; struct LP_address *ap,*tmp;
if ( coin->electrum != 0 )//&& coin->electrumzeroconf != 0 )
return;
HASH_ITER(hh,coin->addresses,ap,tmp)
{
ap->zeroconf_credits = 0;
ap->instantdex_credits = 0;
}
if ( (array= LP_listreceivedbyaddress("KMD",BOTS_BONDADDRESS)) != 0 )
{
@ -271,7 +271,7 @@ int64_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue)
if ( (coin= LP_coinfind("KMD")) != 0 && (pubp= LP_pubkeyfind(pubkey)) != 0 )
{
bitcoin_address(coinaddr,coin->taddr,coin->pubtype,pubp->pubsecp,33);
if ((ap= LP_address(coin,coinaddr)) != 0 )//&& ap->zeroconf_credits >= kmdvalue )
if ((ap= LP_address(coin,coinaddr)) != 0 )//&& ap->instantdex_credits >= kmdvalue )
{
DL_FOREACH_SAFE(pubp->bobswaps,ptr,tmp)
{
@ -285,7 +285,7 @@ int64_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue)
}
//printf("%s zeroconf_credits %.8f vs (%.8f + current %.8f)\n",coinaddr,dstr(ap->zeroconf_credits),dstr(swaps_kmdvalue),dstr(kmdvalue));
//if ( ap->zeroconf_credits > swaps_kmdvalue+kmdvalue )
return(ap->zeroconf_credits - (swaps_kmdvalue+kmdvalue));
return(ap->instantdex_credits - (swaps_kmdvalue+kmdvalue));
}
}
return(0);

Loading…
Cancel
Save