diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 6f32b9372..76cf7f0e3 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -18,7 +18,16 @@ // marketmaker // -char *portstrs[][2] = { { "BTC", "8332" }, { "KMD", "7771" }, { "LTC", "9332" }, { "REVS", "10196" }, { "JUMBLR", "15106" }, }; +char *portstrs[][2] = { { "BTC", "8332" }, { "KMD", "7771" }, { "REVS", "10196" }, { "JUMBLR", "15106" }, }; + +uint16_t LP_rpcport(char *symbol) +{ + int32_t i; + for (i=0; isymbol,symbol,sizeof(coin->symbol)); + sprintf(coin->serverport,"127.0.0.1:%u",port); + coin->longestchain = longestchain; + coin->txfee = txfee; + coin->estimatedrate = estimatedrate; + coin->pubtype = pubtype; + coin->p2shtype = p2shtype; + coin->wiftype = wiftype; + LP_userpass(coin->userpass,symbol,"",name); +} + +struct iguana_info *LP_coinadd(struct iguana_info *cdata) { - struct iguana_info *coin,cdata; int32_t i; uint16_t port; + struct iguana_info *coin; + //printf("%s: (%s) (%s)\n",symbol,cdata.serverport,cdata.userpass); + LP_coins = realloc(LP_coins,sizeof(*LP_coins) * (LP_numcoins+1)); + coin = &LP_coins[LP_numcoins]; + *coin = *cdata; + LP_numcoins++; + return(coin); +} + +struct iguana_info *LP_coinsearch(char *symbol) +{ + int32_t i; for (i=0; i", "rpcport":pppp}, {"coin":"LTC", "name":"litecoin", "rpcport":9332, "pubtype":48, "p2shtype":5, "wiftype":176, "txfee":100000 }] + +struct iguana_info *LP_coincreate(cJSON *item) +{ + struct iguana_info cdata; int32_t longestchain = 1000000; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name,*symbol; + if ( (symbol= jstr(item,"coin")) != 0 && symbol[0] != 0 && strlen(symbol) < 16 && LP_coinfind(symbol) == 0 && (port= juint(item,"rpcport")) != 0 ) { - cdata.pubtype = 60; - cdata.p2shtype = 85; - cdata.wiftype = 188; - LP_userpass(cdata.userpass,symbol,symbol,strcmp(symbol,"KMD") == 0 ? "komodo" : symbol); + if ( (txfee= j64bits(item,"txfee")) == 0 ) + txfee = 10000; + if ( (estimatedrate= jdouble(item,"estimatedrate")) == 0. ) + estimatedrate = 20; + if ( (pubtype= juint(item,"pubtype")) == 0 ) + pubtype = 60; + if ( (p2shtype= juint(item,"p2shtype")) == 0 ) + p2shtype = 85; + if ( (wiftype= juint(item,"wiftype")) == 0 ) + wiftype = 188; + if ( (name= jstr(item,"name")) == 0 ) + name = symbol; + LP_coininit(&cdata,symbol,name,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain); + return(LP_coinadd(&cdata)); } - //printf("%s: (%s) (%s)\n",symbol,cdata.serverport,cdata.userpass); - LP_coins = realloc(LP_coins,sizeof(*LP_coins) * (LP_numcoins+1)); - coin = &LP_coins[LP_numcoins++]; - *coin = cdata; - return(coin); + return(0); } diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 621c7544b..366ab2556 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -38,6 +38,8 @@ double LP_query(char *method,struct LP_quoteinfo *qp,char *ipaddr,uint16_t port, if ( bits256_nonz(qp->desthash) != 0 ) flag = 1; jaddstr(reqjson,"method",method); + if ( strcmp(method,"price") != 0 ) + printf("QUERY.(%s)\n",jprint(reqjson,0)); LP_send(pushsock,jprint(reqjson,1),1); for (i=0; i<30; i++) { diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index d1eba8e7c..9b194a908 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -37,7 +37,7 @@ //#define BASILISK_DISABLEWAITTX //#define BASILISK_DISABLESENDTX -#define LP_PROPAGATION_SLACK 10 // txid ordering is not enforced, so getting extra recent txid +#define LP_PROPAGATION_SLACK 100 // txid ordering is not enforced, so getting extra recent txid #define LP_RESERVETIME 60 #define LP_AVETXSIZE 200 #define LP_CACHEDURATION 60 diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index c58d99a51..f31e3c1ef 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -54,6 +54,7 @@ void tradebot_pendingadd(cJSON *tradejson,char *base,double basevolume,char *rel { // add to trades } + char *LP_getdatadir() { return(USERHOME); @@ -77,10 +78,10 @@ char *blocktrail_listtransactions(char *symbol,char *coinaddr,int32_t num,int32_ #include "LP_quotes.c" #include "LP_commands.c" -void LP_mainloop(struct LP_peerinfo *mypeer,uint16_t mypubport,int32_t pubsock,int32_t pullsock,uint16_t myport,int32_t amclient,char *passphrase,double profitmargin) +void LP_mainloop(struct LP_peerinfo *mypeer,uint16_t mypubport,int32_t pubsock,int32_t pullsock,uint16_t myport,int32_t amclient,char *passphrase,double profitmargin,cJSON *coins) { //static uint16_t tmpport; - char *retstr; uint8_t r; int32_t i,n,j,len,recvsize,counter=0,nonz,lastn; struct LP_peerinfo *peer,*tmp; uint32_t now; struct LP_utxoinfo *utxo,*utmp; void *ptr; cJSON *argjson; + char *retstr; uint8_t r; int32_t i,n,j,len,recvsize,counter=0,nonz,lastn; struct LP_peerinfo *peer,*tmp; uint32_t now; struct LP_utxoinfo *utxo,*utmp; void *ptr; cJSON *argjson,*item; if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport) != 0 ) { printf("error launching stats rpcloop for port.%u\n",myport); @@ -112,6 +113,11 @@ void LP_mainloop(struct LP_peerinfo *mypeer,uint16_t mypubport,int32_t pubsock,i LP_coinfind(activecoins[i]); LP_priceinfoadd(activecoins[i]); } + if ( (n= cJSON_GetArraySize(coins)) > 0 ) + { + for (i=0; i