Browse Source

Merge branch 'dev' of https://github.com/jl777/SuperNET into dev-decker-dev

patch-3
DeckerSU 7 years ago
parent
commit
5ccacc9b44
  1. 3
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_include.h
  3. 12
      iguana/exchanges/LP_remember.c
  4. 15
      iguana/exchanges/LP_rpc.c
  5. 10
      iguana/exchanges/mm.c
  6. 13
      iguana/m_mm

3
iguana/exchanges/LP_commands.c

@ -199,7 +199,8 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
authenticated = 1;
else printf("passhash %s != G %s\n",bits256_str(str,passhash),bits256_str(str2,G.LP_passhash));
}
if ( authenticated == 0 && ((userpass= jstr(argjson,"userpass")) == 0 || strcmp(userpass,G.USERPASS) != 0) )
char passhashstr[65]; bits256_str(passhashstr,G.LP_passhash);
if ( authenticated == 0 && ((userpass= jstr(argjson,"userpass")) == 0 || (strcmp(userpass,G.USERPASS) != 0 && strcmp(userpass,passhashstr) != 0)) )
return(clonestr("{\"error\":\"authentication error you need to make sure userpass is set\"}"));
if ( jobj(argjson,"userpass") != 0 )
jdelete(argjson,"userpass");

2
iguana/exchanges/LP_include.h

@ -305,7 +305,7 @@ struct iguana_info
int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport,did_addrutxo_reset;
uint32_t txversion,dPoWtime,lastresetutxo,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime;
uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms;
char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64];
char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64],estimatefeestr[32];
// portfolio
double price_kmd,force,perc,goal,goalperc,relvolume,rate;
void *electrum; void *ctx;

12
iguana/exchanges/LP_remember.c

@ -395,7 +395,7 @@ int32_t basilisk_isbobcoin(int32_t iambob,int32_t ind)
}
}
int32_t basilisk_swap_isfinished(uint32_t expiration,int32_t iambob,bits256 *txids,int32_t *sentflags,bits256 paymentspent,bits256 Apaymentspent,bits256 depositspent)
int32_t basilisk_swap_isfinished(uint32_t requestid,uint32_t quoteid,uint32_t expiration,int32_t iambob,bits256 *txids,int32_t *sentflags,bits256 paymentspent,bits256 Apaymentspent,bits256 depositspent)
{
int32_t i,n = 0; uint32_t now = (uint32_t)time(NULL);
if ( bits256_nonz(paymentspent) != 0 && bits256_nonz(Apaymentspent) != 0 && bits256_nonz(depositspent) != 0 )
@ -404,7 +404,7 @@ int32_t basilisk_swap_isfinished(uint32_t expiration,int32_t iambob,bits256 *txi
{
if ( sentflags[BASILISK_ALICECLAIM] != 0 )
{
printf("edge case unspendable alicepayment\n");
printf("edge case unspendable alicepayment %u-%u\n",requestid,quoteid);
return(1);
}
else if ( iambob != 0 && sentflags[BASILISK_ALICECLAIM] != 0 )
@ -447,7 +447,7 @@ int32_t basilisk_swap_isfinished(uint32_t expiration,int32_t iambob,bits256 *txi
if ( bits256_nonz(depositspent) != 0 )
{
if ( bits256_nonz(Apaymentspent) == 0 && sentflags[BASILISK_BOBREFUND] == 0 )
printf("bob was too late in claiming bobrefund\n");
printf("bob was too late in claiming bobrefund %u-%u\n",requestid,quoteid);
return(1);
}
}
@ -756,7 +756,7 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t
}
free_json(txobj);
}
rswap->origfinishedflag = basilisk_swap_isfinished(rswap->expiration,rswap->iambob,rswap->txids,rswap->sentflags,rswap->paymentspent,rswap->Apaymentspent,rswap->depositspent);
rswap->origfinishedflag = basilisk_swap_isfinished(requestid,quoteid,rswap->expiration,rswap->iambob,rswap->txids,rswap->sentflags,rswap->paymentspent,rswap->Apaymentspent,rswap->depositspent);
rswap->finishedflag = rswap->origfinishedflag;
if ( forceflag != 0 )
rswap->finishedflag = rswap->origfinishedflag = 0;
@ -1115,7 +1115,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
rswap.paymentspent = basilisk_swap_spendupdate(rswap.iambob,rswap.bobcoin,rswap.bobpaymentaddr,rswap.sentflags,rswap.txids,BASILISK_BOBPAYMENT,BASILISK_ALICESPEND,BASILISK_BOBRECLAIM,0,srcAdest,srcBdest,rswap.Adestaddr,rswap.destaddr);
rswap.Apaymentspent = basilisk_swap_spendupdate(rswap.iambob,rswap.alicecoin,rswap.alicepaymentaddr,rswap.sentflags,rswap.txids,BASILISK_ALICEPAYMENT,BASILISK_ALICERECLAIM,BASILISK_BOBSPEND,0,destAdest,destBdest,rswap.Adestaddr,rswap.destaddr);
rswap.depositspent = basilisk_swap_spendupdate(rswap.iambob,rswap.bobcoin,rswap.bobdepositaddr,rswap.sentflags,rswap.txids,BASILISK_BOBDEPOSIT,BASILISK_ALICECLAIM,BASILISK_BOBREFUND,0,srcAdest,srcBdest,rswap.Adestaddr,rswap.destaddr);
rswap.finishedflag = basilisk_swap_isfinished(rswap.expiration,rswap.iambob,rswap.txids,rswap.sentflags,rswap.paymentspent,rswap.Apaymentspent,rswap.depositspent);
rswap.finishedflag = basilisk_swap_isfinished(requestid,quoteid,rswap.expiration,rswap.iambob,rswap.txids,rswap.sentflags,rswap.paymentspent,rswap.Apaymentspent,rswap.depositspent);
LP_spends_set(&rswap);
if ( rswap.iambob == 0 )
{
@ -1322,7 +1322,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
LP_totals_update(rswap.iambob,rswap.alicecoin,rswap.bobcoin,KMDtotals,BTCtotals,rswap.sentflags,rswap.values);
if ( (numspent= LP_spends_set(&rswap)) == 3 )
rswap.finishedflag = 1;
else rswap.finishedflag = basilisk_swap_isfinished(rswap.expiration,rswap.iambob,rswap.txids,rswap.sentflags,rswap.paymentspent,rswap.Apaymentspent,rswap.depositspent);
else rswap.finishedflag = basilisk_swap_isfinished(requestid,quoteid,rswap.expiration,rswap.iambob,rswap.txids,rswap.sentflags,rswap.paymentspent,rswap.Apaymentspent,rswap.depositspent);
if ( rswap.origfinishedflag == 0 && rswap.finishedflag != 0 )
{
char fname[1024],*itemstr; FILE *fp;

15
iguana/exchanges/LP_rpc.c

@ -602,14 +602,17 @@ cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag)
double _LP_getestimatedrate(struct iguana_info *coin)
{
char buf[512],*retstr=0; int32_t numblocks; cJSON *errjson,*retjson; double rate = 0.00000020;
char buf[512],*retstr=0; int32_t numblocks,err=0; cJSON *errjson,*retjson; double rate = 0.00000020;
if ( coin->rate < 0. || time(NULL) > coin->ratetime+30 )
{
if ( coin->estimatefeestr[0] == 0 )
strcpy(coin->estimatefeestr,"estimatefee");
numblocks = strcmp(coin->symbol,"BTC") == 0 ? 6 : 2;
again:
if ( coin->electrum == 0 )
{
sprintf(buf,"[%d]",numblocks);
retstr = LP_apicall(coin,"estimatefee",buf);
retstr = LP_apicall(coin,coin->estimatefeestr,buf);
}
else
{
@ -621,7 +624,10 @@ double _LP_getestimatedrate(struct iguana_info *coin)
if ( retstr[0] == '{' && (errjson= cJSON_Parse(retstr)) != 0 )
{
if ( jobj(errjson,"error") != 0 )
{
rate = 0.;
err++;
}
free_json(errjson);
}
else if ( retstr[0] != '-' )
@ -638,6 +644,11 @@ double _LP_getestimatedrate(struct iguana_info *coin)
coin->ratetime = (uint32_t)time(NULL);
}
free(retstr);
if ( err == 1 && coin->electrum == 0 && strcmp("BTC",coin->symbol) == 0 )
{
strcpy(coin->estimatefeestr,"estimatesmartfee");
goto again;
}
} else rate = coin->rate;
} else rate = coin->rate;
return(rate);

10
iguana/exchanges/mm.c

@ -156,7 +156,7 @@ int32_t ensure_writable(char *dirname)
int main(int argc, const char * argv[])
{
char dirname[512],*passphrase; double incr; cJSON *retjson;
char dirname[512]; double incr; cJSON *retjson;
OS_init();
if ( strstr(argv[0],"btc2kmd") != 0 && argv[1] != 0 )
{
@ -338,10 +338,10 @@ int main(int argc, const char * argv[])
DOCKERFLAG = 1;
else if ( jstr(retjson,"docker") != 0 )
DOCKERFLAG = (uint32_t)calc_ipbits(jstr(retjson,"docker"));
if ( jobj(retjson,"passphrase") != 0 )
jdelete(retjson,"passphrase");
if ( (passphrase= jstr(retjson,"passphrase")) == 0 )
jaddstr(retjson,"passphrase","default");
//if ( jobj(retjson,"passphrase") != 0 )
// jdelete(retjson,"passphrase");
//if ( (passphrase= jstr(retjson,"passphrase")) == 0 )
// jaddstr(retjson,"passphrase","default");
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_main,(void *)retjson) != 0 )
{
printf("error launching LP_main (%s)\n",jprint(retjson,0));

13
iguana/m_mm

@ -1,14 +1,11 @@
#!/bin/bash
cd secp256k1; ./m_unix; cd ..
cd ../crypto777; ./m_LP; cd ../iguana
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Linux"
# Default is dynamic nanomsg for linux using this script
nanomsg_lib="-lnanomsg"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
echo "Mac OSX"
# on osx this script generates static libnanomsg and uses it to compile static marketmaker binary
nanomsg_lib="-lnanomsg"
# Build static libnanomsg on macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
./build_static_nanomsg.sh
nanomsg_lib="../OSlibs/osx/$(uname -m)/libnanomsg-static.a"
fi

Loading…
Cancel
Save