diff --git a/crypto777/bitcoind_RPC.c b/crypto777/bitcoind_RPC.c index d6c6f69f4..775ec5f66 100755 --- a/crypto777/bitcoind_RPC.c +++ b/crypto777/bitcoind_RPC.c @@ -74,7 +74,7 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char * char *retstr = 0; cJSON *json,*result,*error; #ifdef FROM_MARKETMAKER - //usleep(3000); + //usleep(500); #endif //printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr); if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 ) @@ -280,6 +280,7 @@ try_again: *retstrp = retstr; return(retstr); } +//printf("%s <- %s\n",url,command); return(post_process_bitcoind_RPC(debugstr,command,retstr,params)); } else diff --git a/crypto777/jpeg/unix/jmemname.c b/crypto777/jpeg/unix/jmemname.c index fd09935aa..b738d4f21 100755 --- a/crypto777/jpeg/unix/jmemname.c +++ b/crypto777/jpeg/unix/jmemname.c @@ -70,7 +70,11 @@ extern void free JPP((void *ptr)); */ #ifndef TEMP_DIRECTORY /* can override from jconfig.h or Makefile */ -#define TEMP_DIRECTORY "/usr/tmp/" /* recommended setting for Unix */ +#ifdef _WIN32 +#define TEMP_DIRECTORY "" /* recommended setting for Unix */ +#else +#define TEMP_DIRECTORY "/tmp/" /* recommended setting for Unix */ +#endif #endif static int next_file_num; /* to distinguish among several temp files */ diff --git a/iguana/exchanges/LP_NXT.c b/iguana/exchanges/LP_NXT.c index 81ab96131..6bc320925 100644 --- a/iguana/exchanges/LP_NXT.c +++ b/iguana/exchanges/LP_NXT.c @@ -213,6 +213,7 @@ cJSON *LP_NXT_redeems() //printf("calling (%s)\n",url); if ( (retstr= issue_curlt(url,LP_HTTP_TIMEOUT)) != 0 ) { + //printf("got.(%s)\n",retstr); if ( (retjson= cJSON_Parse(retstr)) != 0 ) { if ( (array= jarray(&numtx,retjson,"transactions")) != 0 ) @@ -298,7 +299,7 @@ cJSON *LP_NXT_redeems() //free_json(retjson); } free(retstr); - } + } else printf("null return from NXT api call\n"); printf("\nTotal redeemed.%d\n",numtx); for (past_marker=0; past_marker<2; past_marker++) { diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 4ddcda058..0343acc0b 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2052,13 +2052,23 @@ bits256 bits256_calcaddrhash(char *symbol,uint8_t *serialized,int32_t len) int32_t bitcoin_addr2rmd160(char *symbol,uint8_t taddr,uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr) { bits256 hash; uint8_t *buf,_buf[26],data5[128],rmd21[21]; char prefixaddr[64],hrp[64]; int32_t len,len5,offset; - if ( strcmp(symbol,"BCH") == 0 && strlen(coinaddr) == 42 ) + if ( coinaddr == 0 || coinaddr[0] == 0 ) + { + *addrtypep = 0; + memset(rmd160,0,20); + return(0); + } + if ( strcmp(symbol,"BCH") == 0 )//&& strlen(coinaddr) == 42 ) { - strcpy(prefixaddr,"bitcoincash:"); - strcat(prefixaddr,coinaddr); + char *bchprefix = "bitcoincash:"; + if ( strncmp(coinaddr,bchprefix,strlen(bchprefix)) != 0 ) + { + strcpy(prefixaddr,bchprefix); + strcat(prefixaddr,coinaddr); + } else strcpy(prefixaddr,coinaddr); if ( bech32_decode(hrp,data5,&len5,prefixaddr) == 0 ) { - printf("bitcoin_addr2rmd160 bech32_decode error.(%s)\n",coinaddr); + printf("bitcoin_addr2rmd160 bech32_decode error.(%s)\n",prefixaddr); return(0); } len = 0; @@ -2157,7 +2167,7 @@ void bitcoin_priv2pub(void *ctx,char *symbol,uint8_t *pubkey33,char *coinaddr,bi int32_t bitcoin_validaddress(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2shtype,char *coinaddr) { - uint8_t rmd160[20],addrtype; char checkaddr[128]; + uint8_t rmd160[20],addrtype; char checkaddr[64],checkaddr2[64]; if ( coinaddr == 0 || coinaddr[0] == 0 ) return(-1); else if ( bitcoin_addr2rmd160(symbol,taddr,&addrtype,rmd160,coinaddr) < 0 ) @@ -2169,7 +2179,9 @@ int32_t bitcoin_validaddress(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t return(-1); else if ( bitcoin_address(symbol,checkaddr,addrtype,taddr,rmd160,sizeof(rmd160)) != checkaddr || strcmp(checkaddr,coinaddr) != 0 ) { - printf("bitcoin_validaddress checkaddr.%s != %s\n",checkaddr,coinaddr); + bitcoin_addr2rmd160(symbol,taddr,&addrtype,rmd160,coinaddr); + bitcoin_address(symbol,checkaddr2,addrtype,taddr,rmd160,sizeof(rmd160)); + printf("%s pubtype.%d taddr.%d bitcoin_validaddress checkaddr.%s != %s, checkaddr2.(%s)\n",symbol,pubtype,taddr,checkaddr,coinaddr,checkaddr2); return(-1); } return(0); @@ -2213,24 +2225,18 @@ int32_t bitcoin_wif2priv(char *symbol,uint8_t wiftaddr,uint8_t *addrtypep,bits25 if ( (len= bitcoin_base58decode(buf,wifstr)) >= 4 ) { if ( len >= 32+offset ) + { memcpy(privkeyp,buf+offset,32); + /*if ( len > 32+offset ) + printf("wif %s: extra byte %d len.%d vs %d addrtype.%d\n",wifstr,buf[32+offset],len,32+offset,(wiftaddr == 0) ? buf[0] : buf[1]); + else printf("%s is for uncompressed\n",wifstr);*/ + } else { - //printf("wif %s -> buf too short len.%d\n",wifstr,len); + printf("wif %s -> buf too short len.%d\n",wifstr,len); return(-1); } ptr = buf; - /*if ( len < 38 ) - { - memset(pbuf,0,sizeof(pbuf)); - memcpy(pbuf,buf,len-4); - memcpy(&pbuf[34],&buf[len-4],4); - ptr = pbuf; - int32_t i; for (i=0; i<38; i++) - printf("%02x ",pbuf[i]); - printf("pbuf from %d\n",len); - len = 38; - }*/ hash = bits256_calcaddrhash(symbol,ptr,len - 4); *addrtypep = (wiftaddr == 0) ? *ptr : ptr[1]; if ( strcmp(symbol,"GRS") != 0 && (ptr[len - 4]&0xff) == hash.bytes[31] && (ptr[len - 3]&0xff) == hash.bytes[30] &&(ptr[len - 2]&0xff) == hash.bytes[29] && (ptr[len - 1]&0xff) == hash.bytes[28] ) @@ -2283,7 +2289,7 @@ int32_t bitcoin_priv2wif(char *symbol,uint8_t wiftaddr,char *wifstr,bits256 priv memcpy(data+offset,privkey.bytes,len); data[offset + len++] = 1; len = base58encode_checkbuf(symbol,wiftaddr,addrtype,data,len); - if ( bitcoin_base58encode(wifstr,data,len) == 0 ) + if ( bitcoin_base58encode(wifstr,data,len) == 0 ) // skips last byte? { char str[65]; printf("error making wif from %s\n",bits256_str(str,privkey)); return(-1); diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 07be2166b..4134936bf 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -368,7 +368,7 @@ uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asse coin->p2shtype = p2shtype; coin->wiftype = wiftype; coin->inactive = (uint32_t)time(NULL); - coin->bussock = LP_coinbus(busport); + //coin->bussock = LP_coinbus(busport); if ( ctx == 0 ) ctx = bitcoin_ctx(); coin->ctx = ctx; diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index a3e508e67..94186c659 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -103,7 +103,7 @@ char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *r return(clonestr("{\"result\":\" \ available localhost RPC commands: \n \ setprice(base, rel, price, broadcast=1)\n\ -autoprice(base, rel, fixed, minprice, margin, refbase, refrel, factor, offset)*\n\ +autoprice(base, rel, fixed, minprice, maxprice, margin, refbase, refrel, factor, offset)*\n\ goal(coin=*, val=)\n\ myprice(base, rel)\n\ enable(coin)\n\ @@ -123,7 +123,7 @@ sendrawtransaction(coin, signedtx)\n\ swapstatus(pending=0)\n\ swapstatus(coin, limit=10)\n\ swapstatus(base, rel, limit=10)\n\ -swapstatus(requestid, quoteid)\n\ +swapstatus(requestid, quoteid, pending=0)\n\ recentswaps(limit=3)\n\ notarizations(coin)\n\ public API:\n \ @@ -131,7 +131,7 @@ getcoins()\n\ getcoin(coin)\n\ portfolio()\n\ getpeers()\n\ -passphrase(passphrase, gui)\n\ +passphrase(passphrase, gui, netid=0, seednode="")\n\ listunspent(coin, address)\n\ setconfirms(coin, numconfirms, maxconfirms=6)\n\ trust(pubkey, trust) # positive to trust, 0 for normal, negative to blacklist\n\ @@ -161,7 +161,7 @@ bot_stop(botid)\n\ bot_pause(botid)\n\ instantdex_deposit(weeks, amount, broadcast=1)\n\ instantdex_claim()\n\ -jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\ +jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ \"}")); //sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\ @@ -183,6 +183,7 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\ init_hexbytes_noT(pub33str,G.LP_pubsecp,33); jaddstr(retjson,"pubsecp",pub33str); jadd(retjson,"coins",LP_coinsjson(LP_showwif)); + LP_cmdcount++; return(jprint(retjson,1)); } // if passphrase api and passphrase is right, ignore userpass, use hass of passphrase @@ -198,11 +199,12 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\ return(clonestr("{\"error\":\"authentication error you need to make sure userpass is set\"}")); if ( jobj(argjson,"userpass") != 0 ) jdelete(argjson,"userpass"); + LP_cmdcount++; if ( strcmp(method,"passphrase") == 0 ) { char coinaddr[64],pub33str[67]; G.USERPASS_COUNTER = 1; - if ( LP_passphrase_init(jstr(argjson,"passphrase"),jstr(argjson,"gui")) < 0 ) + if ( LP_passphrase_init(jstr(argjson,"passphrase"),jstr(argjson,"gui"),juint(argjson,"netid"),jstr(argjson,"seednode")) < 0 ) return(clonestr("{\"error\":\"couldnt change passphrase\"}")); { retjson = cJSON_CreateObject(); @@ -240,7 +242,7 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\ } else if ( strcmp(method,"jpg") == 0 ) { - return(LP_jpg(jstr(argjson,"srcfile"),jstr(argjson,"destfile"),jint(argjson,"power2"),jstr(argjson,"passphrase"),jstr(argjson,"data"),jint(argjson,"required"))); + return(LP_jpg(jstr(argjson,"srcfile"),jstr(argjson,"destfile"),jint(argjson,"power2"),jstr(argjson,"password"),jstr(argjson,"data"),jint(argjson,"required"),juint(argjson,"ind"))); } /*else if ( strcmp(method,"sendmessage") == 0 ) { @@ -268,7 +270,8 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\ else if ( strcmp(method,"stop") == 0 ) { printf("DEBUG stop\n"); - exit(0); + LP_STOP_RECEIVED = 1; + return(clonestr("{\"result\":\"success\"}")); } else if ( strcmp(method,"millis") == 0 ) { @@ -570,7 +573,7 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\ { ptr->privkeydepth = 0; LP_address_utxo_reset(ptr); - LP_passphrase_init(jstr(argjson,"passphrase"),G.gui); + LP_passphrase_init(jstr(argjson,"passphrase"),G.gui,G.netid,G.seednode); } if ( bits256_nonz(G.LP_privkey) != 0 ) LP_privkey_init(-1,ptr,G.LP_privkey,G.LP_mypub25519); @@ -650,7 +653,7 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\ else if ( strcmp(method,"notify") == 0 ) return(LP_notify_recv(argjson)); else if ( strcmp(method,"getpeers") == 0 ) - retstr = clonestr("{\"error\":\"deprecated\"}"); + return(LP_peers()); else if ( strcmp(method,"balances") == 0 ) return(jprint(LP_balances(jstr(argjson,"address")),1)); else if ( strcmp(method,"fundvalue") == 0 ) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 6705e8e6d..96a94c08d 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -55,7 +55,7 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping #define LP_MAXVINS 64 #define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL) -#define LP_AUTOTRADE_TIMEOUT 60 +#define LP_AUTOTRADE_TIMEOUT 30 #define LP_RESERVETIME 600 //(LP_AUTOTRADE_TIMEOUT * 2) #define ELECTRUM_TIMEOUT 13 #define LP_ELECTRUM_KEEPALIVE 60 @@ -299,7 +299,7 @@ struct iguana_info UT_hash_handle hh; portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses; uint64_t txfee; - int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,bussock,height; uint16_t busport; + int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport; uint32_t txversion,dPoWtime,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]; @@ -351,7 +351,7 @@ struct LP_address struct LP_address_utxo *utxos; bits256 pubkey; int64_t balance,total,instantdex_credits; - uint32_t timestamp,n,unspenttime; + uint32_t timestamp,n,unspenttime,instantdextime; int32_t unspentheight; char coinaddr[64]; uint8_t pubsecp[33],didinstantdex; @@ -363,7 +363,7 @@ struct LP_peerinfo uint64_t ip_port; uint32_t recvtime,numrecv,ipbits,errortime,errors,numpeers,needping,lasttime,connected,lastutxos,lastpeers,diduquery,good,sessionid; int32_t pushsock,subsock,isLP; - uint16_t port; + uint16_t port,netid; char ipaddr[64]; }; @@ -416,7 +416,7 @@ struct LP_swapstats uint64_t aliceid; int32_t bobneeds_dPoW,aliceneeds_dPoW; uint32_t ind,methodind,finished,expired,lasttime,dPoWfinished; - char alicegui[32],bobgui[32]; + char alicegui[65],bobgui[65]; }; struct LP_pubswap { struct LP_pubswap *next,*prev; struct LP_swapstats *swap; }; @@ -487,7 +487,7 @@ int64_t LP_listunspent_parseitem(struct iguana_info *coin,bits256 *txidp,int32_t void LP_unspents_cache(char *symbol,char *addr,char *arraystr,int32_t updatedflag); uint16_t LP_psock_get(char *connectaddr,char *publicaddr,int32_t ispaired); //void LP_utxo_clientpublish(struct LP_utxoinfo *utxo); -int32_t LP_coinbus(uint16_t coin_busport); +//int32_t LP_coinbus(uint16_t coin_busport); int32_t LP_nanomsg_recvs(void *ctx); int32_t LP_numconfirms(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int32_t mempool); void LP_aliceid(uint32_t tradeid,uint64_t aliceid,char *event,uint32_t requestid,uint32_t quoteid); @@ -517,7 +517,8 @@ struct LP_address_utxo *LP_address_utxofind(struct iguana_info *coin,char *coina int64_t LP_myzcredits(); void test_validate(struct iguana_info *coin,char *signedtx); void LP_instantdex_depositadd(char *coinaddr,bits256 txid); -int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits256 txid,char *refaddr); +int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits256 txid,char *refaddr,char *origcoinaddr); +void LP_ports(uint16_t *pullportp,uint16_t *pubportp,uint16_t *busportp,uint16_t netid); int32_t LP_destaddr(char *destaddr,cJSON *item); int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int32_t duration); cJSON *LP_statslog_disp(uint32_t starttime,uint32_t endtime,char *refgui,bits256 refpubkey,char *refbase,char *refrel); @@ -556,6 +557,7 @@ struct LP_utxoinfo *_LP_utxo2find(int32_t iambob,bits256 txid,int32_t vout); int64_t LP_dynamictrust(int64_t credits,bits256 pubkey,int64_t kmdvalue); struct LP_address *LP_addressfind(struct iguana_info *coin,char *coinaddr); int64_t LP_outpoint_amount(char *symbol,bits256 txid,int32_t vout); +void LP_initpeers(int32_t pubsock,struct LP_peerinfo *mypeer,char *myipaddr,uint16_t myport,uint16_t netid,char *seednode); void LP_listunspent_query(char *symbol,char *coinaddr); int32_t bitcoin_priv2wif(char *symbol,uint8_t wiftaddr,char *wifstr,bits256 privkey,uint8_t addrtype); diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index 372024655..e10f991ea 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -133,7 +133,7 @@ void LP_instantdex_depositadd(char *coinaddr,bits256 txid) { prevtxid = jbits256i(array,i); //char str[65]; printf("instantdex iter.%d i.%d check %s\n",iter,i,bits256_str(str,prevtxid)); - if ( LP_instantdex_creditcalc(coin,0,prevtxid,coinaddr) > 0 ) + if ( LP_instantdex_creditcalc(coin,0,prevtxid,coinaddr,coinaddr) > 0 ) { LP_instantdex_deposituniq(fp,prevtxid); fflush(fp); @@ -400,7 +400,7 @@ int64_t LP_instantdex_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,in return(0); } -int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits256 txid,char *refaddr) +int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits256 txid,char *refaddr,char *origcoinaddr) { cJSON *txjson,*vouts,*txobj,*item; int64_t satoshis=0,amount64; int32_t weeki,numvouts; char destaddr[64],p2shaddr[64]; if ( (txjson= LP_gettx(coin->symbol,txid,0)) != 0 ) @@ -410,7 +410,7 @@ int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits2 { if ( refaddr != 0 && strcmp(refaddr,destaddr) != 0 ) { - printf("LP_instantdex_creditcalc for (%s) but deposit sent for (%s)\n",refaddr,destaddr); + printf("LP_instantdex_creditcalc for (%s) but deposit sent for orig.(%s) (%s)\n",refaddr,origcoinaddr,destaddr); } else { @@ -435,7 +435,7 @@ int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits2 } #ifdef bruteforce -void LP_instantdex_deposits(struct iguana_info *coin) +/*void LP_instantdex_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; @@ -463,7 +463,7 @@ void LP_instantdex_deposits(struct iguana_info *coin) free_json(array); } dispflag = 0; -} +}*/ #endif int64_t LP_dynamictrust(int64_t credits,bits256 pubkey,int64_t kmdvalue) @@ -510,14 +510,19 @@ int64_t LP_dynamictrust(int64_t credits,bits256 pubkey,int64_t kmdvalue) int64_t LP_instantdex_proofcheck(char *symbol,char *coinaddr,cJSON *proof,int32_t num) { - uint8_t rmd160[20],addrtype; int64_t credits=0; int32_t i,j; bits256 prevtxid,txid; char othersmartaddr[64]; struct iguana_info *coin; struct LP_address *ap = 0; + uint8_t rmd160[20],addrtype,taddr=0; int64_t credits=0; int32_t i,j; bits256 prevtxid,txid; char othersmartaddr[64]; struct iguana_info *coin,*origcoin; struct LP_address *ap = 0; if ( (coin= LP_coinfind("KMD")) != 0 ) { - bitcoin_addr2rmd160(symbol,0,&addrtype,rmd160,coinaddr); - bitcoin_address("KMD",othersmartaddr,0,60,rmd160,20); + if ( (origcoin= LP_coinfind(symbol)) != 0 ) + taddr = origcoin->taddr; + bitcoin_addr2rmd160(symbol,taddr,&addrtype,rmd160,coinaddr); + bitcoin_address("KMD",othersmartaddr,coin->taddr,coin->pubtype,rmd160,20); //printf("proofcheck addrtype.%d (%s) -> %s\n",addrtype,coinaddr,othersmartaddr); if ((ap= LP_address(coin,othersmartaddr)) != 0 ) { + if ( time(NULL) < ap->instantdextime+300 ) + return(ap->instantdex_credits); + ap->instantdextime = (uint32_t)time(NULL); ap->instantdex_credits = 0; for (i=0; iinstantdex_credits; ap->didinstantdex = 1; + ap->instantdextime = (uint32_t)time(NULL); if ( 0 && ap->instantdex_credits > 0 ) printf("validated instantdex %s.[%d] proof.(%s) credits %.8f\n",othersmartaddr,num,jprint(proof,0),dstr(ap->instantdex_credits)); } //else printf("cant find ap.%p or already did %d %.8f\n",ap,ap!=0?ap->didinstantdex:-1,ap!=0?dstr(ap->instantdex_credits):-1); diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 8c6782259..1fe39f0b9 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -98,11 +98,11 @@ struct LP_address_utxo *LP_garbage_collector2; struct LP_trade *LP_trades,*LP_tradesQ; //uint32_t LP_deadman_switch; -uint16_t LP_fixed_pairport,LP_publicport; +uint16_t LP_fixed_pairport;//,LP_publicport; uint32_t LP_lastnonce,LP_swap_endcritical,LP_swap_critical,LP_RTcount,LP_swapscount; -int32_t LP_mybussock = -1; +int32_t LP_STOP_RECEIVED,LP_numactive_LP;//,LP_mybussock = -1; int32_t LP_mypubsock = -1; -int32_t LP_mypullsock = -1; +int32_t LP_cmdcount,LP_mypullsock = -1; int32_t LP_numfinished,LP_showwif,IAMLP = 0; double LP_profitratio = 1.; @@ -113,10 +113,11 @@ struct LP_globals //struct LP_utxoinfo *LP_utxoinfos[2],*LP_utxoinfos2[2]; bits256 LP_mypub25519,LP_privkey,LP_mypriv25519,LP_passhash; uint64_t LP_skipstatus[10000]; + uint16_t netid; uint8_t LP_myrmd160[20],LP_pubsecp[33]; uint32_t LP_sessionid,counter; int32_t LP_IAMLP,LP_pendingswaps,USERPASS_COUNTER,LP_numprivkeys,initializing,waiting,LP_numskips; - char USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[16],LP_NXTaddr[64]; + char seednode[64],USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[65],LP_NXTaddr[64]; struct LP_privkey LP_privkeys[100]; } G; @@ -134,12 +135,12 @@ uint32_t LP_rand() char *activecoins[] = { "BTC", "KMD" }; char GLOBAL_DBDIR[] = { "DB" }; -char LP_myipaddr[64],LP_publicaddr[64],USERHOME[512] = { "/root" }; -char LP_gui[16] = { "cli" }; +char LP_myipaddr[64],USERHOME[512] = { "/root" }; +char LP_gui[65] = { "cli" }; -char *default_LPnodes[] = { "5.9.253.195", "5.9.253.196", "5.9.253.197", "5.9.253.198", "5.9.253.199", "5.9.253.200", "5.9.253.201", "5.9.253.202", "5.9.253.203", +char *default_LPnodes[] = { "5.9.253.195", "173.212.225.176", "136.243.45.140", "23.254.202.142", "45.32.19.196" //"24.54.206.138", "107.72.162.127", "72.50.16.86", "51.15.202.191", "173.228.198.88", - "51.15.203.171", "51.15.86.136", "51.15.94.249", "51.15.80.18", "51.15.91.40", "51.15.54.2", "51.15.86.31", "51.15.82.29", "51.15.89.155", "173.212.225.176", "136.243.45.140" + //"51.15.203.171", "51.15.86.136", "51.15.94.249", "51.15.80.18", "51.15.91.40", "51.15.54.2", "51.15.86.31", "51.15.82.29", "51.15.89.155", "173.212.225.176", "136.243.45.140" }; // stubs @@ -249,8 +250,8 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock, if ( duplicate != 0 ) dup++; else uniq++; - portable_mutex_lock(&LP_commandmutex); - if ( (LP_rand() % 10000) == 0 ) + //portable_mutex_lock(&LP_commandmutex); + if ( (LP_rand() % 100000) == 0 ) printf("%s dup.%d (%u / %u) %.1f%% encrypted.%d recv.%u [%02x %02x] vs %02x %02x\n",typestr,duplicate,dup,dup+uniq,(double)100*dup/(dup+uniq),encrypted,crc32,ptr[0],ptr[1],crc32&0xff,(crc32>>8)&0xff); if ( duplicate == 0 ) { @@ -339,7 +340,7 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock, free_json(argjson); } } //else printf("DUPLICATE.(%s)\n",(char *)ptr); - portable_mutex_unlock(&LP_commandmutex); + //portable_mutex_unlock(&LP_commandmutex); if ( jsonstr != 0 && (void *)jsonstr != (void *)ptr && encrypted == 0 ) free(jsonstr); return(retstr); @@ -365,6 +366,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int ptr = 0; if ( (recvlen= nn_recv(sock,&ptr,NN_MSG,0)) > 0 ) { + //printf("%s nn_recv.%d\n",typestr,recvlen); decodestr = 0; if ( recvlen > 32768 ) { @@ -387,7 +389,6 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int } else printf("couldnt decode linebuf[%d]\n",recvlen); } methodstr[0] = 0; - //printf("%s.(%s)\n",typestr,(char *)ptr); if ( recvjson != 0 ) { safecopy(LP_methodstr,jstr(recvjson,"method"),sizeof(LP_methodstr)); @@ -413,13 +414,13 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int Broadcaststr = 0; if ( (argjson= cJSON_Parse(str)) != 0 ) { - portable_mutex_lock(&LP_commandmutex); + //portable_mutex_lock(&LP_commandmutex); if ( LP_tradecommand(ctx,myipaddr,pubsock,argjson,0,0) <= 0 ) { if ( (retstr= stats_JSON(ctx,myipaddr,pubsock,argjson,remoteaddr,0)) != 0 ) free(retstr); } - portable_mutex_unlock(&LP_commandmutex); + //portable_mutex_unlock(&LP_commandmutex); free_json(argjson); } free(str); @@ -441,13 +442,13 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int int32_t LP_nanomsg_recvs(void *ctx) { - int32_t nonz = 0; char *origipaddr; struct LP_peerinfo *peer,*tmp; + int32_t n=0,nonz = 0; char *origipaddr; struct LP_peerinfo *peer,*tmp; if ( (origipaddr= LP_myipaddr) == 0 ) origipaddr = "127.0.0.1"; //portable_mutex_lock(&LP_nanorecvsmutex); HASH_ITER(hh,LP_peerinfos,peer,tmp) { - if ( peer->errors >= LP_MAXPEER_ERRORS ) + if ( n++ > 0 && peer->errors >= LP_MAXPEER_ERRORS ) { if ( (LP_rand() % 10000) == 0 ) peer->errors--; @@ -457,8 +458,7 @@ int32_t LP_nanomsg_recvs(void *ctx) continue; } } - //printf("check %s pubsock.%d\n",peer->ipaddr,peer->subsock); - nonz += LP_sock_check("PULL",ctx,origipaddr,LP_mypubsock,peer->subsock,peer->ipaddr,1); + nonz += LP_sock_check("SUB",ctx,origipaddr,LP_mypubsock,peer->subsock,peer->ipaddr,1); } /*HASH_ITER(hh,LP_coins,coin,ctmp) // firstrefht,firstscanht,lastscanht { @@ -469,7 +469,7 @@ int32_t LP_nanomsg_recvs(void *ctx) }*/ if ( LP_mypullsock >= 0 ) { - nonz += LP_sock_check("SUB",ctx,origipaddr,-1,LP_mypullsock,"127.0.0.1",1); + nonz += LP_sock_check("PULL",ctx,origipaddr,-1,LP_mypullsock,"127.0.0.1",1); } //portable_mutex_unlock(&LP_nanorecvsmutex); return(nonz); @@ -480,7 +480,7 @@ void command_rpcloop(void *ctx) int32_t nonz = 0; strcpy(command_rpcloop_stats.name,"command_rpcloop"); command_rpcloop_stats.threshold = 2500.; - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { LP_millistats_update(&command_rpcloop_stats); nonz = LP_nanomsg_recvs(ctx); @@ -515,8 +515,13 @@ void LP_coinsloop(void *_coins) strcpy(LP_coinsloop_stats.name,"other coins loop"); LP_coinsloop_stats.threshold = 5000.; } - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { + if ( strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") == 0 ) + { + sleep(10); + continue; + } if ( strcmp("BTC",coins) == 0 ) LP_millistats_update(&LP_coinsloopBTC_stats); else if ( strcmp("KMD",coins) == 0 ) @@ -539,7 +544,10 @@ void LP_coinsloop(void *_coins) } } if ( coin->smartaddr[0] == 0 ) + { printf("%s has no smartaddress??\n",coin->symbol); + continue; + } memset(&zero,0,sizeof(zero)); if ( coin->inactive != 0 ) continue; @@ -663,7 +671,7 @@ void LP_coinsloop(void *_coins) } } -int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int32_t pubsock,char *pushaddr,uint16_t myport) +int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int32_t pubsock) { static uint32_t counter;//,didinstantdex; struct iguana_info *coin,*ctmp; char *origipaddr; uint32_t now; int32_t notarized,height,nonz = 0; @@ -736,8 +744,9 @@ void bech32_tests() { //char *test = "an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs"; //char *test = "bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a"; - char *test = "bitcoincash:qr95sy3j9xwd2ap32xkykttr4cvcu7as4y0qverfuy"; + //char *test = "bitcoincash:qr95sy3j9xwd2ap32xkykttr4cvcu7as4y0qverfuy"; //char *test = "prefix:x64nx6hz"; + char *test = "bitcoincash:pq4p38fll9uuh2mzkesqhmgt66du4u0zzy92jchqqa"; // 35Xbnq3kLoNsjN67knFewiRc9fqewrCzMW uint8_t data[82],data2[64],rmd160[21],addrtype; char rebuild[92],hrp[84]; int32_t data_len,data_len2; int32_t i; if ( bech32_decode(hrp,data,&data_len,test) == 0 ) { @@ -745,26 +754,28 @@ void bech32_tests() } else { - bitcoin_addr2rmd160("BCH",0,&addrtype,rmd160,"qr95sy3j9xwd2ap32xkykttr4cvcu7as4y0qverfuy"); + bitcoin_addr2rmd160("BCH",0,&addrtype,rmd160,"pq4p38fll9uuh2mzkesqhmgt66du4u0zzy92jchqqa"); + bitcoin_address("BTC",rebuild,0,5,rmd160,20); for (i=0; i<20; i++) printf("%02x",rmd160[i]); - printf("addr2rmd160 %d\n",addrtype); + printf("addr2rmd160 %d -> %s\n",addrtype,rebuild); + data_len2 = 0; if ( bech32_convert_bits(data2,&data_len2,8,data,data_len,5,0) == 0 ) printf("error converting data5\n"); for (i=0; i %d\n",data_len2); - bitcoin_addr2rmd160("BTC",0,&addrtype,rmd160+1,"1KXrWXciRDZUpQwQmuM1DbwsKDLYAYsVLR"); + bitcoin_addr2rmd160("BTC",0,&addrtype,rmd160+1,"35Xbnq3kLoNsjN67knFewiRc9fqewrCzMW"); for (i=0; i ",(int32_t)data_len,test,"1KXrWXciRDZUpQwQmuM1DbwsKDLYAYsVLR"); + printf(" datalen.%d <- %s (%s) -> ",(int32_t)data_len,test,"35Xbnq3kLoNsjN67knFewiRc9fqewrCzMW"); for (i=0; i<20; i++) printf("%02x",rmd160[i+1]); printf("\n"); } data_len2 = 0; - rmd160[0] = (0 << 3); + rmd160[0] = (1 << 3); bech32_convert_bits(data2,&data_len2,5,rmd160,21,8,1); for (i=0; i 0 && netid < 9) && (seednode == 0 || seednode[0] == 0) ) + { + sprintf(fixedseed,"5.9.253.%d",195 + netid); + seednode = fixedseed; + } if ( seednode == 0 || seednode[0] == 0 ) { - //LP_addpeer(mypeer,pubsock,"51.15.86.136",myport,pushport,subport,0,G.LP_sessionid); + printf("default seed nodes for netid.%d\n",netid); OS_randombytes((void *)&r,sizeof(r)); - //r = 0; - for (j=0; j lasttime+LP_ORDERBOOK_DURATION*0.5 ) + if ( strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") != 0 ) { -//printf("LP_pubkeysloop %u\n",(uint32_t)time(NULL)); - LP_notify_pubkeys(ctx,LP_mypubsock); - lasttime = (uint32_t)time(NULL); + LP_millistats_update(&LP_pubkeysloop_stats); + if ( time(NULL) > lasttime+100 ) + { + //printf("LP_pubkeysloop %u\n",(uint32_t)time(NULL)); + LP_notify_pubkeys(ctx,LP_mypubsock); + lasttime = (uint32_t)time(NULL); + } } sleep(3); } @@ -907,12 +928,15 @@ void LP_swapsloop(void *ctx) strcpy(LP_swapsloop_stats.name,"LP_swapsloop"); LP_swapsloop_stats.threshold = 605000.; sleep(50); - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { - LP_millistats_update(&LP_swapsloop_stats); - if ( (retstr= basilisk_swapentry(0,0,0)) != 0 ) - free(retstr); - sleep(600); + if ( strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") != 0 ) + { + LP_millistats_update(&LP_swapsloop_stats); + if ( (retstr= basilisk_swapentry(0,0,0)) != 0 ) + free(retstr); + sleep(600); + } else sleep(10); } } @@ -921,7 +945,7 @@ void gc_loop(void *ctx) uint32_t now; struct LP_address_utxo *up,*utmp; struct rpcrequest_info *req,*rtmp; int32_t flag = 0; strcpy(LP_gcloop_stats.name,"gc_loop"); LP_gcloop_stats.threshold = 11000.; - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { flag = 0; LP_millistats_update(&LP_gcloop_stats); @@ -956,7 +980,7 @@ void queue_loop(void *ctx) struct LP_queue *ptr,*tmp; cJSON *json; uint8_t linebuf[32768]; int32_t k,sentbytes,nonz,flag,duplicate,n=0; strcpy(queue_loop_stats.name,"queue_loop"); queue_loop_stats.threshold = 1000.; - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { LP_millistats_update(&queue_loop_stats); //printf("LP_Q.%p next.%p prev.%p\n",LP_Q,LP_Q!=0?LP_Q->next:0,LP_Q!=0?LP_Q->prev:0); @@ -995,11 +1019,13 @@ void queue_loop(void *ctx) printf("%d LP_send mmjson sent %d instead of %d\n",n,sentbytes,k); else flag++; } + //printf("k.%d SEND.(%s) sock.%d\n",k,(char *)ptr->msg,ptr->sock); } free_json(json); } if ( flag == 0 ) { + //printf("len.%d SEND.(%s) sock.%d\n",ptr->msglen,(char *)ptr->msg,ptr->sock); if ( (sentbytes= nn_send(ptr->sock,ptr->msg,ptr->msglen,0)) != ptr->msglen ) printf("%d LP_send sent %d instead of %d\n",n,sentbytes,ptr->msglen); else flag++; @@ -1062,8 +1088,8 @@ void LP_reserved_msgs(void *ignore) bits256 zero; int32_t flag,nonz; struct nn_pollfd pfd; memset(zero.bytes,0,sizeof(zero)); strcpy(LP_reserved_msgs_stats.name,"LP_reserved_msgs"); - LP_reserved_msgs_stats.threshold = 150.; - while ( 1 ) + LP_reserved_msgs_stats.threshold = 1000.; + while ( LP_STOP_RECEIVED == 0 ) { nonz = 0; LP_millistats_update(&LP_reserved_msgs_stats); @@ -1110,6 +1136,8 @@ void LP_reserved_msgs(void *ignore) int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,char *msg) { int32_t n = 0; + if ( strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") == 0 ) + return(-1); portable_mutex_lock(&LP_reservedmutex); if ( num_Reserved_msgs[priority] < sizeof(Reserved_msgs[priority])/sizeof(*Reserved_msgs[priority]) ) { @@ -1130,7 +1158,7 @@ extern int32_t bitcoind_RPC_inittime; void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybusport,char *passphrase,int32_t amclient,char *userhome,cJSON *argjson) { - char *myipaddr=0,version[64]; long filesize,n; int32_t valid,timeout,pubsock=-1; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128],*coins_str=0; cJSON *coinsjson=0; void *ctx = bitcoin_ctx(); + char *myipaddr=0,version[64]; long filesize,n; int32_t valid,timeout; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128],*coins_str=0; cJSON *coinsjson=0; void *ctx = bitcoin_ctx(); sprintf(version,"Marketmaker %s.%s %s rsize.%ld",LP_MAJOR_VERSION,LP_MINOR_VERSION,LP_BUILD_NUMBER,sizeof(struct basilisk_request)); bitcoind_RPC_inittime = 1; printf("%s %u\n",version,calc_crc32(0,version,(int32_t)strlen(version))); @@ -1227,43 +1255,31 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu #endif if ( IAMLP != 0 ) { - pubsock = -1; + G.netid = juint(argjson,"netid"); + LP_mypubsock = -1; nanomsg_transportname(0,subaddr,myipaddr,mypubport); nanomsg_transportname(1,bindaddr,myipaddr,mypubport); - //nanomsg_transportname2(1,bindaddr2,myipaddr,mypubport); valid = 0; - if ( (pubsock= nn_socket(AF_SP,NN_PUB)) >= 0 ) + if ( (LP_mypubsock= nn_socket(AF_SP,NN_PUB)) >= 0 ) { valid = 0; - if ( nn_bind(pubsock,bindaddr) >= 0 ) + if ( nn_bind(LP_mypubsock,bindaddr) >= 0 ) valid++; - //if ( nn_bind(pubsock,bindaddr2) >= 0 ) - // valid++; if ( valid > 0 ) { timeout = 1; - nn_setsockopt(pubsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); + nn_setsockopt(LP_mypubsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); } else { - printf("error binding to (%s).%d\n",subaddr,pubsock); - if ( pubsock >= 0 ) - nn_close(pubsock), pubsock = -1; + printf("error binding to (%s).%d\n",subaddr,LP_mypubsock); + if ( LP_mypubsock >= 0 ) + nn_close(LP_mypubsock), LP_mypubsock = -1; } - } else printf("error getting pubsock %d\n",pubsock); - printf(">>>>>>>>> myipaddr.(%s) (%s) pullsock.%d valid.%d\n",bindaddr,subaddr,pubsock,valid); - LP_mypubsock = pubsock; + } else printf("error getting pubsock %d\n",LP_mypubsock); + printf(">>>>>>>>> myipaddr.(%s) (%s) valid.%d pubbindaddr.%s pubsock.%d\n",bindaddr,subaddr,valid,bindaddr,LP_mypubsock); + LP_mypullsock = LP_initpublicaddr(ctx,&mypullport,pushaddr,myipaddr,mypullport,0); } - printf("got %s, initpeers\n",myipaddr); - LP_initpeers(pubsock,mypeer,myipaddr,myport,jstr(argjson,"seednode"),mypullport,mypubport); - RPC_port = myport; - printf("get public socket\n"); - LP_mypullsock = LP_initpublicaddr(ctx,&mypullport,pushaddr,myipaddr,mypullport,0); - strcpy(LP_publicaddr,pushaddr); - LP_publicport = mypullport; - LP_mybussock = LP_coinbus(mybusport); - //LP_deadman_switch = (uint32_t)time(NULL); - printf("canbind.%d my command address is (%s) pullsock.%d pullport.%u\n",LP_canbind,pushaddr,LP_mypullsock,mypullport); if ( (coinsjson= jobj(argjson,"coins")) == 0 ) { if ( (coins_str= OS_filestr(&filesize,"coins.json")) != 0 || (coins_str= OS_filestr(&filesize,"exchanges/coins.json")) != 0 ) @@ -1280,9 +1296,16 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("no coins object or coins.json file, must abort\n"); exit(-1); } - LP_initcoins(ctx,pubsock,coinsjson); + LP_initcoins(ctx,LP_mypubsock,coinsjson); + RPC_port = myport; G.waiting = 1; - LP_passphrase_init(passphrase,jstr(argjson,"gui")); + LP_initpeers(LP_mypubsock,LP_mypeer,LP_myipaddr,RPC_port,juint(argjson,"netid"),jstr(argjson,"seednode")); + //LP_mypullsock = LP_initpublicaddr(ctx,&mypullport,pushaddr,myipaddr,mypullport,0); + //strcpy(LP_publicaddr,pushaddr); + //LP_publicport = mypullport; + //LP_mybussock = LP_coinbus(mybusport); + printf("got %s, initpeers. LP_mypubsock.%d pullsock.%d RPC_port.%u mypullport.%d mypubport.%d pushaddr.%s\n",myipaddr,LP_mypubsock,LP_mypullsock,RPC_port,mypullport,mypubport,pushaddr); + LP_passphrase_init(passphrase,jstr(argjson,"gui"),juint(argjson,"netid"),jstr(argjson,"seednode")); #ifndef FROM_JS if ( IAMLP != 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_psockloop,(void *)myipaddr) != 0 ) { @@ -1299,12 +1322,6 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching stats rpcloop for port.%u\n",myport); exit(-1); } - uint16_t myport2 = myport-1; - if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport2) != 0 ) - { - printf("error launching stats rpcloop for port.%u\n",myport); - exit(-1); - } if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)command_rpcloop,ctx) != 0 ) { printf("error launching command_rpcloop for ctx.%p\n",ctx); @@ -1355,26 +1372,40 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu printf("error launching LP_swapsloop for ctx.%p\n",ctx); exit(-1); } - int32_t nonz; + int32_t nonz,didremote=0; LP_statslog_parse(); bitcoind_RPC_inittime = 0; - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { nonz = 0; G.waiting = 1; - while ( G.initializing != 0 ) + while ( G.initializing != 0 && strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") == 0 ) { //fprintf(stderr,"."); sleep(3); } - if ( LP_mainloop_iter(ctx,myipaddr,mypeer,pubsock,pushaddr,myport) != 0 ) + if ( LP_mainloop_iter(ctx,myipaddr,mypeer,LP_mypubsock) != 0 ) nonz++; + if ( didremote == 0 && LP_cmdcount > 0 ) + { + didremote = 1; + uint16_t myport2 = RPC_port-1; + printf("start remote port\n"); + if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)stats_rpcloop,(void *)&myport2) != 0 ) + { + printf("error launching stats rpcloop for port.%u\n",myport); + exit(-1); + } + } if ( nonz == 0 ) usleep(1000); else if ( IAMLP == 0 ) usleep(1000); } #endif + printf("marketmaker exiting in 5 seconds\n"); + sleep(5); + exit(0); } #ifdef FROM_JS @@ -1429,7 +1460,7 @@ void LP_fromjs_iter() //LP_pubkeys_query(); //LP_utxosQ_process(); //LP_nanomsg_recvs(ctx); - LP_mainloop_iter(ctx,LP_myipaddr,0,LP_mypubsock,LP_publicaddr,LP_RPCPORT); + LP_mainloop_iter(ctx,LP_myipaddr,0,LP_mypubsock); //queue_loop(0); if ( 0 ) // 10 seconds { diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index e3755aae6..891cdd975 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -156,7 +156,7 @@ void _LP_sendqueueadd(uint32_t crc32,int32_t sock,uint8_t *msg,int32_t msglen,in memcpy(ptr->msg,msg,msglen); // sizeof(bits256) at the end all zeroes DL_APPEND(LP_Q,ptr); LP_Qenqueued++; - //printf("Q.%p: peerind.%d msglen.%d\n",ptr,peerind,msglen); + //printf("Q.%p: peerind.%d msglen.%d sock.%d\n",ptr,peerind,msglen,sock); } uint32_t _LP_magic_check(bits256 hash,bits256 magic) @@ -213,7 +213,7 @@ int32_t LP_magic_check(uint8_t *msg,int32_t recvlen,char *remoteaddr) int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32) { - static uint32_t crcs[4096]; static unsigned long dup,total; + static uint32_t crcs[16384]; static unsigned long dup,total; int32_t i; *duplicatep = 0; if ( ind < 0 ) @@ -304,10 +304,11 @@ void LP_broadcast_finish(int32_t pubsock,char *base,char *rel,uint8_t *msg,cJSON msglen = (int32_t)strlen((char *)msg) + 1; if ( crc32 == 0 ) crc32 = calc_crc32(0,&msg[2],msglen - 2); + //printf("crc32.%x IAMLP.%d pubsock.%d\n",crc32,G.LP_IAMLP,pubsock); #ifdef FROM_MARKETMAKER - if ( G.LP_IAMLP == 0 ) + if ( G.LP_IAMLP == 0 || pubsock < 0 ) #else - if ( IAMLP == 0 ) + if ( IAMLP == 0 || pubsock < 0 ) #endif { free(msg); @@ -320,7 +321,13 @@ void LP_broadcast_finish(int32_t pubsock,char *base,char *rel,uint8_t *msg,cJSON msg = (void *)jprint(argjson,0); msglen = (int32_t)strlen((char *)msg) + 1; LP_queuesend(crc32,-1,base,rel,msg,msglen); - } else LP_queuesend(crc32,pubsock,base,rel,msg,msglen); + if ( pubsock >= 0 ) + LP_queuesend(crc32,pubsock,base,rel,msg,msglen); + } + else + { + LP_queuesend(crc32,pubsock,base,rel,msg,msglen); + } free(msg); } @@ -410,8 +417,8 @@ void LP_psockloop(void *_ptr) // printouts seem to be needed for forwarding to w static struct nn_pollfd *pfds; int32_t i,n,nonz,iter,retval,sentbytes,size=0,sendsock = -1; uint32_t now; struct psock *ptr=0; void *buf=0; char keepalive[512]; strcpy(LP_psockloop_stats.name,"LP_psockloop"); - LP_psockloop_stats.threshold = 200.; - while ( 1 ) + LP_psockloop_stats.threshold = 1000.; + while ( LP_STOP_RECEIVED == 0 ) { LP_millistats_update(&LP_psockloop_stats); now = (uint32_t)time(NULL); @@ -733,7 +740,7 @@ int32_t LP_initpublicaddr(void *ctx,uint16_t *mypullportp,char *publicaddr,char *mypullportp = 0; if ( ispaired == 0 ) { - strcpy(publicaddr,"127.0.0.1"); + sprintf(publicaddr,"127.0.0.1:%u",mypullport); return(-1); } while ( *mypullportp == 0 ) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 810abb632..3ec680e96 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -481,11 +481,9 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double bits256 zero; memset(zero.bytes,0,sizeof(zero)); LP_reserved_msg(1,base,rel,zero,jprint(reqjson,0)); - //if ( IAMLP == 0 ) - { - sleep(1); - LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); - } + sleep(1); + LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); + sleep(1); LP_reserved_msg(0,base,rel,zero,jprint(reqjson,0)); free_json(reqjson); LP_importaddress(qp->destcoin,qp->destaddr); @@ -910,12 +908,12 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru bits256 zero; memset(zero.bytes,0,sizeof(zero)); LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); - //if ( IAMLP == 0 ) + if ( 0 )//if ( IAMLP == 0 ) { sleep(1); LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); } - LP_reserved_msg(0,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); + //LP_reserved_msg(0,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); free_json(reqjson); return(qp); } else printf("request processing selected ineligible utxos?\n"); @@ -1016,7 +1014,7 @@ void LP_tradesloop(void *ctx) strcpy(LP_tradesloop_stats.name,"LP_tradesloop"); LP_tradesloop_stats.threshold = 10000; sleep(5); - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { LP_millistats_update(&LP_tradesloop_stats); nonz = 0; @@ -1169,7 +1167,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, LP_quoteparse(&Q,argjson); LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis-Q.txfee,Q.destcoin,Q.destsatoshis-Q.desttxfee,Q.timestamp,Q.quotetime,DEXselector); LP_tradecommand_log(argjson); - printf("%-4d (%-10u %10u) %12s id.%22llu %5s/%-5s %12.8f -> %11.8f price %11.8f | RT.%d %d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount); + printf("%-4d (%-10u %10u) %12s id.%-20llu %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount,G.netid); //LP_autoprices_update(method,Q.srccoin,dstr(Q.satoshis),Q.destcoin,dstr(Q.destsatoshis)); retval = 1; aliceid = j64bits(argjson,"aliceid"); diff --git a/iguana/exchanges/LP_peers.c b/iguana/exchanges/LP_peers.c index 593046706..dc324666f 100644 --- a/iguana/exchanges/LP_peers.c +++ b/iguana/exchanges/LP_peers.c @@ -32,7 +32,8 @@ cJSON *LP_peerjson(struct LP_peerinfo *peer) { cJSON *item = cJSON_CreateObject(); jaddstr(item,"isLP",peer->ipaddr); - jaddnum(item,"port",peer->port); + jaddnum(item,"remoteport",peer->port-1); + jaddnum(item,"netid",peer->netid); if ( strcmp(peer->ipaddr,LP_myipaddr) == 0 ) { jaddnum(item,"session",G.LP_sessionid); @@ -55,7 +56,7 @@ char *LP_peers() return(jprint(peersjson,1)); } -struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char *ipaddr,uint16_t port,uint16_t pushport,uint16_t subport,int32_t isLP,uint32_t sessionid) +struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char *ipaddr,uint16_t port,uint16_t pushport,uint16_t subport,int32_t isLP,uint32_t sessionid,uint16_t netid) { uint32_t ipbits; int32_t valid,pushsock,subsock,timeout; char checkip[64],pushaddr[64],subaddr[64]; struct LP_peerinfo *peer = 0; #ifdef LP_STRICTPEERS @@ -68,8 +69,16 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char { if ( (peer= LP_peerfind(ipbits,port)) != 0 ) { - if ( isLP != 0 ) - peer->isLP = isLP; + if ( peer->netid != netid ) + { + printf("netid mismatch for %s? %d vs %d\n",peer->ipaddr,peer->netid,G.netid); + return(0); + } + if ( isLP != 0 && peer->isLP == 0 ) + { + if ( (peer->isLP= isLP) != 0 ) + LP_numactive_LP++; + } /*if ( numpeers > peer->numpeers ) peer->numpeers = numpeers; if ( numutxos > peer->numutxos ) @@ -77,7 +86,7 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char if ( peer->sessionid == 0 ) peer->sessionid = sessionid;*/ } - else + else if ( IAMLP != 0 || LP_numactive_LP < 3 ) { //printf("addpeer (%s:%u) pushport.%u subport.%u\n",ipaddr,port,pushport,subport); peer = calloc(1,sizeof(*peer)); @@ -86,9 +95,11 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char else peer->sessionid = sessionid; peer->pushsock = peer->subsock = pushsock = subsock = -1; strcpy(peer->ipaddr,ipaddr); + peer->netid = netid; //peer->profitmargin = profitmargin; peer->ipbits = ipbits; - peer->isLP = isLP; + if ( (peer->isLP= isLP) != 0 ) + LP_numactive_LP++; peer->port = port; peer->ip_port = ((uint64_t)port << 32) | ipbits; if ( pushport != 0 && subport != 0 && (pushsock= nn_socket(AF_SP,NN_PUSH)) >= 0 ) @@ -124,7 +135,7 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char if ( valid > 0 ) { peer->subsock = subsock; - printf("connected to sub.(%s) subsock.%d valid.%d\n",subaddr,peer->subsock,valid); + printf("connected to sub.(%s) subsock.%d valid.%d numactive.%d\n",subaddr,peer->subsock,valid,LP_numactive_LP); } else { @@ -140,10 +151,10 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char pushsock = -1; printf("error connecting to push.(%s)\n",pushaddr); } - } else printf("%s pushport.%u subport.%u pushsock.%d\n",ipaddr,pushport,subport,pushsock); + } else printf("%s pushport.%u subport.%u pushsock.%d isLP.%d\n",ipaddr,pushport,subport,pushsock,isLP); if ( peer->pushsock >= 0 && peer->subsock >= 0 ) { - //printf("add peer %s\n",peer->ipaddr); + //printf("add peer %s isLP.%d\n",peer->ipaddr,peer->isLP); portable_mutex_lock(&LP_peermutex); HASH_ADD(hh,LP_peerinfos,ip_port,sizeof(peer->ip_port),peer); if ( mypeer != 0 ) @@ -152,9 +163,9 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char printf("_LPaddpeer %s -> numpeers.%d mypubsock.%d other.(%d)\n",ipaddr,mypeer->numpeers,mypubsock,isLP); } else peer->numpeers = 1; // will become mypeer portable_mutex_unlock(&LP_peermutex); - if ( IAMLP != 0 && mypubsock >= 0 ) + /*if ( IAMLP != 0 && mypubsock >= 0 ) { - struct iguana_info *coin,*ctmp; char busaddr[64]; // + //struct iguana_info *coin,*ctmp; char busaddr[64]; // //memset(zero.bytes,0,sizeof(zero)); //LP_send(mypubsock,msg,(int32_t)strlen(msg)+1,1); //LP_reserved_msg(0,"","",zero,jprint(LP_peerjson(peer),1)); @@ -169,14 +180,30 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char } } } - } + }*/ } else printf("%s invalid pushsock.%d or subsock.%d\n",peer->ipaddr,peer->pushsock,peer->subsock); } } else printf("LP_addpeer: checkip.(%s) vs (%s)\n",checkip,ipaddr); return(peer); } -int32_t LP_coinbus(uint16_t coin_busport) +void LP_closepeers() +{ + struct LP_peerinfo *peer,*tmp; + HASH_ITER(hh,LP_peerinfos,peer,tmp) + { + portable_mutex_lock(&LP_peermutex); + HASH_DELETE(hh,LP_peerinfos,peer); + portable_mutex_unlock(&LP_peermutex); + if ( peer->pushsock >= 0 ) + nn_close(peer->pushsock), peer->pushsock = -1; + if ( peer->subsock >= 0 ) + nn_close(peer->subsock), peer->subsock = -1; + // free(peer); a small memleak to avoid freein inflight requests + } +} + +/*int32_t LP_coinbus(uint16_t coin_busport) { struct LP_peerinfo *peer,*tmp; char busaddr[64]; int32_t timeout,bussock = -1; return(-1); @@ -204,7 +231,7 @@ int32_t LP_coinbus(uint16_t coin_busport) } } return(bussock); -} +}*/ void LP_peer_recv(char *ipaddr,int32_t ismine) { diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index 3476f53c8..ead40b27c 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -300,7 +300,7 @@ void LP_autopriceset(int32_t ind,void *ctx,int32_t dir,struct LP_priceinfo *base { if ( LP_autorefs[ind].lastask < SMALLVAL ) LP_autorefs[ind].lastask = newprice; - else LP_autorefs[ind].lastask = (LP_autorefs[ind].lastask * 0.9) + (0.1 *newprice); + else LP_autorefs[ind].lastask = (LP_autorefs[ind].lastask * 0.99) + (0.01 *newprice); newprice = LP_autorefs[ind].lastask; //printf("autopriceset %s/%s <- %.8f %.8f (%.8f %.8f)\n",basepp->symbol,relpp->symbol,price,newprice,LP_autorefs[ind].lastbid,LP_autorefs[ind].lastask); } @@ -547,36 +547,6 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,base,rel,askprice); //printf("price %.8f -> %.8f %.8f\n",price,bidprice,askprice); } - /*if ( LP_autorefs[i].fundbid[0] != 0 && (price= jdouble(fundjson,LP_autorefs[i].fundbid)) > SMALLVAL ) - { - printf("%s/%s %s %.8f -> %.8f or %.8f",base,rel,LP_autorefs[i].fundbid,price,(1. / (price * (1. + buymargin))),(1. / (price * (1. - buymargin)))); - if ( tickerjson != 0 && LP_autorefs[i].count == 0 ) - price = LP_tickered_price(0,base,rel,price,tickerjson); - newprice = (1. / (price * (1. + buymargin))); - //if ( LP_autorefs[i].lastbid < SMALLVAL ) - LP_autorefs[i].lastbid = newprice; - //else LP_autorefs[i].lastbid = (LP_autorefs[i].lastbid * 0.9) + (0.1 *newprice); - newprice = LP_autorefs[i].lastbid; - LP_mypriceset(&changed,rel,base,newprice); - LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,rel,base,newprice); - printf("fundbid %.8f margin %.8f newprice %.8f\n",price,buymargin,newprice); - } - if ( LP_autorefs[i].fundask[0] != 0 && (price= jdouble(fundjson,LP_autorefs[i].fundask)) > SMALLVAL ) - { - printf("%s/%s %s %.8f -> ",base,rel,LP_autorefs[i].fundask,price); - if ( tickerjson != 0 && LP_autorefs[i].count == 0 ) - price = LP_tickered_price(1,base,rel,price,tickerjson); - newprice = (price * (1. + sellmargin)); - //if ( LP_autorefs[i].lastask < SMALLVAL ) - LP_autorefs[i].lastask = newprice; - //else LP_autorefs[i].lastask = (LP_autorefs[i].lastask * 0.9) + (0.1 *newprice); - if ( LP_autorefs[i].lastbid < SMALLVAL || LP_autorefs[i].lastask >= LP_autorefs[i].lastbid/(1. + sellmargin) ) - newprice = LP_autorefs[i].lastask; - else newprice = LP_autorefs[i].lastbid * (1. + sellmargin); - LP_mypriceset(&changed,base,rel,newprice); - LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,base,rel,newprice); - printf("fundask %.8f margin %.8f newprice %.8f\n",price,sellmargin,newprice); - }*/ LP_autorefs[i].count++; } free_json(fundjson); @@ -596,18 +566,18 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) else continue; if ( factor > 0. ) price = (price * factor) + offset; - newprice = (price * (1. - buymargin)); + newprice = (price * (1. + buymargin)); if ( LP_autorefs[i].lastbid < SMALLVAL ) LP_autorefs[i].lastbid = newprice; - else LP_autorefs[i].lastbid = (LP_autorefs[i].lastbid * 0.9) + (0.1 *newprice); + else LP_autorefs[i].lastbid = (LP_autorefs[i].lastbid * 0.99) + (0.01 * newprice); newprice = LP_autorefs[i].lastbid; LP_mypriceset(&changed,rel,base,newprice); LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,rel,base,newprice); //printf("%s/%s price %.8f margin %.8f/%.8f newprice %.8f %.8f\n",base,rel,price,buymargin,sellmargin,newprice,(1. / newprice) * (1. + sellmargin)); - newprice = (1. / newprice) * (1. + sellmargin); + newprice = (1. / price) * (1. + sellmargin); if ( LP_autorefs[i].lastask < SMALLVAL ) LP_autorefs[i].lastask = newprice; - else LP_autorefs[i].lastask = (LP_autorefs[i].lastask * 0.9) + (0.1 *newprice); + else LP_autorefs[i].lastask = (LP_autorefs[i].lastask * 0.99) + (0.01 * newprice); newprice = LP_autorefs[i].lastask; LP_mypriceset(&changed,base,rel,newprice); LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,base,rel,newprice); @@ -681,6 +651,8 @@ int32_t LP_autoprice(void *ctx,char *base,char *rel,cJSON *argjson) fixedprice = jdouble(argjson,"fixed"); basepp->fixedprices[relpp->ind] = fixedprice; basepp->minprices[relpp->ind] = minprice; + if ( jobj(argjson,"maxprice") != 0 ) + relpp->minprices[basepp->ind] = 1. / jdouble(argjson,"maxprice"); basepp->buymargins[relpp->ind] = buymargin; basepp->sellmargins[relpp->ind] = sellmargin; basepp->offsets[relpp->ind] = offset; @@ -869,7 +841,7 @@ void prices_loop(void *ctx) char *retstr; cJSON *retjson,*array; char *buycoin,*sellcoin; struct iguana_info *buy,*sell; uint32_t requestid,quoteid; int32_t i,n,m; struct LP_portfoliotrade trades[256]; struct LP_priceinfo *btcpp; strcpy(prices_loop_stats.name,"prices_loop"); prices_loop_stats.threshold = 191000.; - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { //printf("prices loop autoprices.%d autorefs.%d\n",LP_autoprices,num_LP_autorefs); LP_millistats_update(&prices_loop_stats); diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 7807f8eaf..cee20a5d2 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -511,7 +511,7 @@ char *LP_myprices() int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) { - struct LP_priceinfo *basepp,*relpp; struct LP_pubkey_info *pubp; + struct LP_priceinfo *basepp,*relpp; struct LP_pubkey_info *pubp; double minprice,maxprice; *changedp = 0; //if ( strcmp("DEX",base) == 0 || strcmp("DEX",rel) == 0 ) // printf("%s/%s setprice %.8f\n",base,rel,price); @@ -529,6 +529,19 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) relpp->offsets[basepp->ind] = 0.; relpp->factors[basepp->ind] = 0.; } + else if ( (minprice= basepp->minprices[relpp->ind]) > SMALLVAL && price < minprice ) + { + printf("%s/%s price %.8f less than minprice %.8f\n",base,rel,price,minprice); + price = minprice; + } + else if ( (maxprice= relpp->minprices[basepp->ind]) > SMALLVAL ) + { + if ( price > (1. / maxprice) ) + { + printf("%s/%s price %.8f less than maxprice %.8f, more than %.8f\n",base,rel,price,maxprice,1./maxprice); + price = (1. / maxprice); + } + } /*else if ( basepp->myprices[relpp->ind] > SMALLVAL ) { price = (basepp->myprices[relpp->ind] * 0.9) + (0.1 * price); @@ -936,6 +949,7 @@ char *LP_orderbook(char *base,char *rel,int32_t duration) jaddstr(retjson,"base",base); jaddstr(retjson,"rel",rel); jaddnum(retjson,"timestamp",now); + jaddnum(retjson,"netid",G.netid); if ( bids != 0 ) free(bids); if ( asks != 0 ) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index ece651338..191c5fde1 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -206,27 +206,48 @@ static const char base58_chars[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijk int32_t LP_wifstr_valid(char *symbol,char *wifstr) { - bits256 privkey,cmpkey; uint8_t wiftype; char cmpstr[128],cmpstr2[128]; int32_t i; + bits256 privkey,cmpkey; uint8_t wiftype; char cmpstr[128],cmpstr2[128]; int32_t i,len,n,a,A; + if ( (len= (int32_t)strlen(wifstr)) < 50 || len > 54 ) + { + //printf("len.%d is wrong for wif %s\n",len,wifstr); + return(0); + } memset(privkey.bytes,0,sizeof(privkey)); memset(cmpkey.bytes,0,sizeof(cmpkey)); - for (i=0; wifstr[i]!=0; i++) + for (i=n=a=A=0; wifstr[i]!=0; i++) + { if ( strchr(base58_chars,wifstr[i]) == 0 ) return(0); + if ( wifstr[i] >= '1' && wifstr[i] <= '9' ) + n++; + else if ( wifstr[i] >= 'A' && wifstr[i] <= 'Z' ) + A++; + else if ( wifstr[i] >= 'a' && wifstr[i] <= 'z' ) + a++; + } + if ( n == 0 || A == 0 || a == 0 ) + return(0); + if ( A > 5*a || a > 5*A || a > n*20 || A > n*20 ) // unlikely it is a real wif + { + printf("reject wif %s due to n.%d a.%d A.%d (%d %d %d %d)\n",wifstr,n,a,A,A > 5*a,a < 5*A,a > n*20,A > n*20); + return(0); + } bitcoin_wif2priv(symbol,0,&wiftype,&privkey,wifstr); bitcoin_priv2wif(symbol,0,cmpstr,privkey,wiftype); if ( strcmp(cmpstr,wifstr) == 0 ) { - printf("%s is valid wif\n",wifstr); + //printf("%s is valid wif\n",wifstr); return(1); } else if ( bits256_nonz(privkey) != 0 ) { bitcoin_wif2priv(symbol,0,&wiftype,&cmpkey,cmpstr); bitcoin_priv2wiflong(symbol,0,cmpstr2,privkey,wiftype); - char str[65],str2[65]; printf("mismatched wifstr %s -> %s -> %s %s %s\n",wifstr,bits256_str(str,privkey),cmpstr,bits256_str(str2,cmpkey),cmpstr2); if ( bits256_cmp(privkey,cmpkey) == 0 ) return(1); + char str[65],str2[65]; printf("%s mismatched wifstr %s -> %s -> %s %s %s\n",symbol,wifstr,bits256_str(str,privkey),cmpstr,bits256_str(str2,cmpkey),cmpstr2); } + char str[65]; printf("%s is not a wif, privkey.%s\n",wifstr,bits256_str(str,privkey)); return(0); } @@ -261,8 +282,12 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2wif(coin->symbol,coin->wiftaddr,tmpstr,privkey,tmptype); if ( strcmp(tmpstr,wifstr) != 0 ) { - printf("error reproducing the wifstr, likely edge case like non-supported uncompressed pubkey\n"); - exit(1); + bitcoin_wif2priv(coin->symbol,coin->wiftaddr,&tmptype,&tmpkey,tmpstr); + if ( bits256_cmp(tmpkey,privkey) != 0 ) + { + char str[65]; printf("%s error reproducing the wifstr, likely edge case like non-supported uncompressed pubkey privkey.%s\n",coin->symbol,bits256_str(str,privkey)); + exit(1); + } } tmpkey = privkey; nxtaddr = conv_NXTpassword(tmpkey.bytes,pubkeyp->bytes,0,0); @@ -345,23 +370,43 @@ void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase) } } -int32_t LP_passphrase_init(char *passphrase,char *gui) +int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seednode) { - static void *ctx; int32_t counter; //iambob,; struct LP_utxoinfo *utxo,*tmp; + static void *ctx; struct iguana_info *coin,*tmp; int32_t counter; if ( ctx == 0 ) ctx = bitcoin_ctx(); if ( G.LP_pendingswaps != 0 ) return(-1); + if ( netid != G.netid ) + { + if ( IAMLP != 0 ) + { + printf("sorry, LP nodes can only set netid during startup\n"); + return(-1); + } + else + { + printf(">>>>>>>>>>>>> netid.%d vs G.netid %d\n",netid,G.netid); + LP_closepeers(); + LP_initpeers(LP_mypubsock,LP_mypeer,LP_myipaddr,RPC_port,netid,seednode); + } + } G.initializing = 1; if ( gui == 0 ) gui = "cli"; counter = G.USERPASS_COUNTER; + HASH_ITER(hh,LP_coins,coin,tmp) + { + coin->importedprivkey = 0; + } while ( G.waiting == 0 ) { printf("waiting for G.waiting\n"); sleep(5); } memset(&G,0,sizeof(G)); + G.netid = netid; + safecopy(G.seednode,seednode,sizeof(G.seednode)); vcalc_sha256(0,G.LP_passhash.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); LP_privkey_updates(ctx,LP_mypubsock,passphrase); init_hexbytes_noT(G.LP_myrmd160str,G.LP_myrmd160,20); @@ -395,10 +440,59 @@ void LP_privkey_tests() } +#define JPG_ENCRYPTED_MAXSIZE 32768 + +int32_t JPG_encrypt(uint16_t ind,uint8_t encoded[JPG_ENCRYPTED_MAXSIZE],uint8_t *msg,int32_t msglen,bits256 privkey) +{ + bits256 pubkey; int32_t len = 2; uint8_t space[JPG_ENCRYPTED_MAXSIZE],*nonce,*cipher; + pubkey = acct777_pubkey(privkey); + encoded[len++] = ind & 0xff; + encoded[len++] = (ind >> 8) & 0xff; + nonce = &encoded[len]; + OS_randombytes(nonce,crypto_box_NONCEBYTES); + cipher = &encoded[len + crypto_box_NONCEBYTES]; + msglen = _SuperNET_cipher(nonce,&encoded[len + crypto_box_NONCEBYTES],msg,msglen,pubkey,privkey,space); + msglen += crypto_box_NONCEBYTES; + msg = encoded; + msglen += len; + encoded[0] = msglen & 0xff; + encoded[1] = (msglen >> 8) & 0xff; + int32_t i; for (i=0; i 0 && cipherlen <= JPG_ENCRYPTED_MAXSIZE + crypto_box_ZEROBYTES ) + { + if ( (extracted= _SuperNET_decipher(nonce,cipher,space,cipherlen,pubkey,privkey)) != 0 ) + { + int32_t i; for (i=0; i 16 ) - power2 = 4; + bits256 privkey; FILE *input_file,*output_file; int32_t recvlen,msglen,val,modified,emit,totalrows,limit,required; uint16_t checkind; uint8_t *decrypted,*space,*data=0; + if ((input_file = fopen(inputfname, READ_BINARY)) == NULL) + { + fprintf(stderr, "Can't open %s\n", inputfname); + //exit(EXIT_FAILURE); + return(-1); + } + required = origrequired; + memset(privkey.bytes,0,sizeof(privkey)); + if ( password != 0 && password[0] != 0 ) + { + if ( required/8 > JPG_ENCRYPTED_MAXSIZE-60 ) + return(-1); + data = calloc(1,required/8+512); + vcalc_sha256(0,privkey.bytes,(uint8_t *)password,(int32_t)strlen(password)); + if ( origdata != 0 ) + { + msglen = JPG_encrypt(*indp,data,origdata,required/8,privkey); + required = msglen * 8; + { + space = calloc(1,JPG_ENCRYPTED_MAXSIZE); + if ( (decrypted= JPG_decrypt(&checkind,&recvlen,space,data,privkey)) == 0 || recvlen != origrequired/8 || checkind != *indp || memcmp(decrypted,origdata,origrequired/8) != 0 ) + printf("A decryption error: checkind.%d vs %d, recvlen.%d vs %d, decrypted.%p\n",checkind,*indp,recvlen,origrequired/8,decrypted); + else + { + for (i=0; i 30 ) + power2 = 7; limit = 1; while ( power2 > 0 ) { limit <<= 1; power2--; } - if ((input_file = fopen(inputfname, READ_BINARY)) == NULL) { - fprintf(stderr, "Can't open %s\n", inputfname); - exit(EXIT_FAILURE); - } // Initialize the JPEG compression and decompression objects with default error handling inputinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&inputinfo); @@ -453,10 +575,14 @@ int32_t LP_jpg_process(int32_t *capacityp,char *inputfname,char *outputfname,uin for (i=0; i power2 ) + if ( val < -limit || val >= limit ) { - if ( decoded != 0 && (val & 1) != 0 && *capacityp < required ) - decoded[*capacityp >> 3] |= (1 << (*capacityp & 7)); + if ( (*capacityp) < required ) + { + if ( (val & 1) != 0 ) + SETBIT(decoded,(*capacityp)); + //printf("%c",(val&1)!=0?'1':'0'); + } (*capacityp)++; } coef_buffers[compnum][rownum][blocknum][i] = val; @@ -464,12 +590,28 @@ int32_t LP_jpg_process(int32_t *capacityp,char *inputfname,char *outputfname,uin } } } - printf("capacity %d required.%d\n",*capacityp,required); + if ( password != 0 && password[0] != 0 ) + { + space = calloc(1,JPG_ENCRYPTED_MAXSIZE); + if ( (decrypted= JPG_decrypt(indp,&recvlen,space,decoded,privkey)) != 0 && recvlen == origrequired/8 ) + { + for (i=0; i required && outputfname != 0 && outputfname[0] != 0 ) { if ((output_file = fopen(outputfname, WRITE_BINARY)) == NULL) { fprintf(stderr, "Can't open %s\n", outputfname); - exit(EXIT_FAILURE); + if ( data != origdata ) + free(data); + return(-1); } outputinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&outputinfo); @@ -483,25 +625,25 @@ int32_t LP_jpg_process(int32_t *capacityp,char *inputfname,char *outputfname,uin for (blocknum=0; blocknum power2 ) + if ( val < -limit || val >= limit ) { val &= ~1; - if ( (data[emit >> 3] & (1 << (emit&7))) != 0 ) + if (GETBIT(data,emit) != 0 )//|| (emit >= required && (rand() & 1) != 0) ) val |= 1; + //printf("%c",(val&1)!=0?'1':'0'); + coef_buffers[compnum][rownum][blocknum][i] = val; emit++; } - coef_buffers[compnum][rownum][blocknum][i] = val; //printf("%i,", coef_buffers[compnum][rownum][blocknum][i]); } } } } - //printf("\n\n"); - - /* Output the new DCT coeffs to a JPEG file */ + //printf(" emit.%d\n",emit); + // Output the new DCT coeffs to a JPEG file modified = 0; for (compnum=0; compnum 0 ) @@ -551,23 +694,36 @@ char *LP_jpg(char *srcfile,char *destfile,int32_t power2,char *passphrase,char * data = calloc(1,len); decode_hex(data,len,datastr); required = len * 8; + //int32_t i; for (i=0; i 0 ) - decoded = calloc(1,len); - modified = LP_jpg_process(&capacity,srcfile,destfile,decoded,data,required,power2,passphrase); - jaddnum(retjson,"modifiedrows",modified); - if ( modified != 0 ) - jaddstr(retjson,"outputfile",destfile); - jaddnum(retjson,"power2",power2); - jaddnum(retjson,"capacity",capacity); - jaddnum(retjson,"required",required); + decoded = calloc(1,len+required); + if ( (modified= LP_jpg_process(&capacity,srcfile,destfile,decoded,data,required,power2,passphrase,&ind)) < 0 ) + jaddstr(retjson,"error","file not found"); + else + { + jaddstr(retjson,"result","success"); + jaddnum(retjson,"modifiedrows",modified); + if ( modified != 0 ) + jaddstr(retjson,"outputfile",destfile); + jaddnum(retjson,"power2",power2); + jaddnum(retjson,"capacity",capacity); + jaddnum(retjson,"required",required); + jaddnum(retjson,"ind",ind); + } if ( decoded != 0 ) { - decodedstr = calloc(1,len*2+1); - init_hexbytes_noT(decodedstr,decoded,len); - jaddstr(retjson,"decoded",decodedstr); - free(decodedstr); + if ( capacity > 0 ) + { + //printf("len.%d required.%d capacity.%d\n",len,required,capacity); + decodedstr = calloc(1,(len+required)*2+1); + init_hexbytes_noT(decodedstr,decoded,required/8); + jaddstr(retjson,"decoded",decodedstr); + free(decodedstr); + } free(decoded); } if ( data != 0 ) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 6abf336b5..995964069 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -489,7 +489,7 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) item = cJSON_CreateObject(); if ( LP_swap_endcritical < LP_swap_critical ) { - jaddstr(item,"warning","swaps in critical section"); + jaddstr(item,"warning","swaps in critical section, dont exit now"); jaddnum(item,"critical",LP_swap_critical); jaddnum(item,"endcritical",LP_swap_endcritical); } @@ -1044,7 +1044,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti free_json(txoutobj), flag = 0; else flag = -1, rswap.depositspent = deadtxid; } - if ( flag == 0 ) + //if ( flag == 0 ) { if ( rswap.Dredeemlen != 0 ) redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); @@ -1119,7 +1119,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti free_json(txoutobj), flag = 0; else flag = -1, rswap.paymentspent = deadtxid; } - if ( flag == 0 && time(NULL) > rswap.expiration+777 ) + if ( time(NULL) > rswap.expiration+777 ) { // bobreclaim redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,zero,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); @@ -1148,7 +1148,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti free_json(txoutobj), flag = 0; else flag = -1, rswap.depositspent = deadtxid; } - if ( flag == 0 && (bits256_nonz(rswap.Apaymentspent) != 0 || time(NULL) > rswap.expiration+777) ) + if ( bits256_nonz(rswap.Apaymentspent) != 0 || time(NULL) > rswap.expiration+777 ) { printf("do the refund! paymentspent.%s now.%u vs expiration.%u\n",bits256_str(str,rswap.paymentspent),(uint32_t)time(NULL),rswap.expiration); //if ( txbytes[BASILISK_BOBREFUND] == 0 ) @@ -1202,7 +1202,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { jaddstr(item,"method","tradestatus"); jaddnum(item,"finishtime",rswap.finishtime); - jaddstr(item,"gui",G.gui); + if ( jobj(item,"gui") == 0 ) + jaddstr(item,"gui",G.gui); //jaddbits256(item,"srchash",rswap.Q.srchash); //jaddbits256(item,"desthash",rswap.desthash); itemstr = jprint(item,0); @@ -1401,7 +1402,7 @@ char *LP_recent_swaps(int32_t limit) jaddnum(subitem,"price",-destamount/srcamount); jaddi(item,subitem); } - } else printf("base.%p rel.%p statusstr.%p baseind.%d relind.%d\n",base,rel,statusstr,baseind,relind); + } //else printf("base.%p rel.%p statusstr.%p baseind.%d relind.%d\n",base,rel,statusstr,baseind,relind); free_json(swapjson); } else printf("error parsing.(%s)\n",retstr); free(retstr); diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index c7918cc71..76a4f820d 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -104,7 +104,7 @@ int32_t LP_getheight(int32_t *notarizedp,struct iguana_info *coin) coin->height = height = jint(retjson,"blocks"); if ( (*notarizedp= jint(retjson,"notarized")) != 0 && *notarizedp != coin->notarized ) { - printf("new notarized %s %d -> %d\n",coin->symbol,coin->notarized,*notarizedp); + //printf("new notarized %s %d -> %d\n",coin->symbol,coin->notarized,*notarizedp); coin->notarized = *notarizedp; coin->notarizationtxid = jbits256(retjson,"notarizedtxid"); coin->notarizedhash = jbits256(retjson,"notarizedhash"); diff --git a/iguana/exchanges/LP_scan.c b/iguana/exchanges/LP_scan.c index defc1b0cd..fdb3801cd 100644 --- a/iguana/exchanges/LP_scan.c +++ b/iguana/exchanges/LP_scan.c @@ -453,7 +453,7 @@ int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int return(-1); } expiration = (uint32_t)time(NULL) + duration; - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { if ( LP_gettx_presence(symbol,txid) != 0 ) numconfirms = 0; diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index e251daabc..00c92a8d8 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -42,7 +42,8 @@ struct basilisk_request *LP_requestinit(struct basilisk_request *rp,bits256 srch cJSON *LP_quotejson(struct LP_quoteinfo *qp) { double price; cJSON *retjson = cJSON_CreateObject(); - jaddstr(retjson,"gui",qp->gui[0] != 0 ? qp->gui : LP_gui); + if ( jobj(retjson,"gui") == 0 ) + jaddstr(retjson,"gui",qp->gui[0] != 0 ? qp->gui : LP_gui); jadd64bits(retjson,"aliceid",qp->aliceid); jaddnum(retjson,"tradeid",qp->tradeid); jaddstr(retjson,"base",qp->srccoin); @@ -542,8 +543,8 @@ void LP_notify_pubkeys(void *ctx,int32_t pubsock) jaddstr(reqjson,"isLP",LPipaddr); if ( strcmp(LPipaddr,LP_myipaddr) == 0 ) jaddnum(reqjson,"ismine",1); - } - else printf("no LPipaddr\n"); + //printf("notify send isLP.%s ismine.%d\n",LPipaddr,strcmp(LPipaddr,LP_myipaddr) == 0); + } else printf("no LPipaddr\n"); } jaddnum(reqjson,"session",G.LP_sessionid); LP_reserved_msg(0,"","",zero,jprint(reqjson,1)); @@ -569,7 +570,7 @@ char *LP_notify_recv(cJSON *argjson) G.LP_IAMLP = 1; } } - LP_addpeer(LP_mypeer,LP_mypubsock,ipaddr,RPC_port,RPC_port+10,RPC_port+20,1,juint(argjson,"session")); + LP_addpeer(LP_mypeer,LP_mypubsock,ipaddr,RPC_port,RPC_port+10,RPC_port+20,1,juint(argjson,"session"),G.netid); } //char str[65]; printf("%.3f NOTIFIED pub %s rmd160 %s\n",OS_milliseconds()-millis,bits256_str(str,pub),rmd160str); } @@ -676,6 +677,7 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_ memset(&zero,0,sizeof(zero)); LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg)); //if ( strcmp(method,"request") == 0 ) + if ( 0 ) { sleep(1); LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg)); diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 4544ed0dc..c754e6bc2 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -433,7 +433,9 @@ cJSON *electrum_submit(char *symbol,struct electrum_info *ep,cJSON **retjsonp,ch if ( *retjsonp == 0 || jobj(*retjsonp,"error") != 0 ) { if ( ++ep->numerrors >= LP_ELECTRUM_MAXERRORS ) - electrum_kickstart(ep); + { + // electrum_kickstart(ep); seems to hurt more than help + } } else if ( ep->numerrors > 0 ) ep->numerrors--; if ( ep->prev == 0 ) diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index 31eacdd9f..1bce64fde 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -201,9 +201,11 @@ int32_t LP_statslog_parse() struct LP_swapstats *LP_swapstats_find(uint64_t aliceid) { struct LP_swapstats *sp; + portable_mutex_lock(&LP_statslogmutex); HASH_FIND(hh,LP_RTstats,&aliceid,sizeof(aliceid),sp); if ( sp == 0 ) HASH_FIND(hh,LP_swapstats,&aliceid,sizeof(aliceid),sp); + portable_mutex_unlock(&LP_statslogmutex); return(sp); } @@ -214,9 +216,11 @@ struct LP_swapstats *LP_swapstats_add(uint64_t aliceid,int32_t RTflag) { sp = calloc(1,sizeof(*sp)); sp->aliceid = aliceid; + portable_mutex_lock(&LP_statslogmutex); if ( RTflag != 0 ) HASH_ADD(hh,LP_RTstats,aliceid,sizeof(aliceid),sp); else HASH_ADD(hh,LP_swapstats,aliceid,sizeof(aliceid),sp); + portable_mutex_unlock(&LP_statslogmutex); } return(LP_swapstats_find(aliceid)); } @@ -742,8 +746,10 @@ cJSON *LP_statslog_disp(uint32_t starttime,uint32_t endtime,char *refgui,bits256 { if ( LP_stats_dispiter(array,sp,starttime,endtime,refbase,refrel,refgui,refpubkey) > 0 ) { + portable_mutex_lock(&LP_statslogmutex); HASH_DELETE(hh,LP_RTstats,sp); HASH_ADD(hh,LP_swapstats,aliceid,sizeof(sp->aliceid),sp); + portable_mutex_unlock(&LP_statslogmutex); } else { diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 3cb2dcbb5..1bf47ebc2 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -635,7 +635,7 @@ cJSON *LP_balances(char *coinaddr) strcpy(address,coin->smartaddr); else { - bitcoin_addr2rmd160(coin->symbol,taddr,&addrtype,rmd160,coinaddr); + bitcoin_addr2rmd160("KMD",taddr,&addrtype,rmd160,coinaddr); bitcoin_address(coin->symbol,address,coin->taddr,coin->pubtype,rmd160,20); //printf("%s taddr.%d addrtype.%u %s -> %s [%c %c].%d\n",coin->symbol,taddr,addrtype,coinaddr,address,coinaddr[0],coinaddr[1],coinaddr[0] == 't' && (coinaddr[1] == '1' || coinaddr[1] == '3')); } diff --git a/iguana/exchanges/auto_chipsbtc b/iguana/exchanges/auto_chipsbtc index e4b2490cc..06c5282e9 100755 --- a/iguana/exchanges/auto_chipsbtc +++ b/iguana/exchanges/auto_chipsbtc @@ -1,2 +1,2 @@ source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"BTC\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}" +curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.00002,\"maxprice\":0.0001,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"BTC\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}" diff --git a/iguana/exchanges/auto_chipskmd b/iguana/exchanges/auto_chipskmd index aee6c0548..c259a8cff 100755 --- a/iguana/exchanges/auto_chipskmd +++ b/iguana/exchanges/auto_chipskmd @@ -1,2 +1,2 @@ source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}" +curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.04,\"maxprice\":0.1,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}" diff --git a/iguana/exchanges/auto_grskmd b/iguana/exchanges/auto_grskmd index 5e4bc927e..59ad21afa 100755 --- a/iguana/exchanges/auto_grskmd +++ b/iguana/exchanges/auto_grskmd @@ -1,2 +1,2 @@ source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"GRS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"groestlcoin\",\"refrel\":\"coinmarketcap\"}" +curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.05,\"maxprice\":0.2,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"GRS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"groestlcoin\",\"refrel\":\"coinmarketcap\"}" diff --git a/iguana/exchanges/client b/iguana/exchanges/client index a36758376..3b33a363a 100755 --- a/iguana/exchanges/client +++ b/iguana/exchanges/client @@ -1,9 +1,10 @@ #!/bin/bash source passphrase source coins -pkill -15 marketmaker; +./stop git pull; cd ..; ./m_mm; +pkill -15 marketmaker; ./marketmaker "{\"gui\":\"nogui\",\"client\":1, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" & diff --git a/iguana/exchanges/coins b/iguana/exchanges/coins index 937f9a103..b41a8b96f 100644 --- a/iguana/exchanges/coins +++ b/iguana/exchanges/coins @@ -1,3 +1,3 @@ -export coins="[{\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":9998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" +export coins="[{\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" #, {\"coin\":\"AUD\",\"asset\":\"AUD\",\"rpcport\":8045}, {\"coin\":\"BGN\",\"asset\":\"BGN\",\"rpcport\":9110}, {\"coin\":\"CAD\",\"asset\":\"CAD\",\"rpcport\":8720}, {\"coin\":\"CHF\",\"asset\":\"CHF\",\"rpcport\":15312}, {\"coin\":\"CNY\",\"asset\":\"CNY\",\"rpcport\":10384}, {\"coin\":\"CZK\",\"asset\":\"CZK\",\"rpcport\":9482}, {\"coin\":\"DKK\",\"asset\":\"DKK\",\"rpcport\":13830}, {\"coin\":\"EUR\",\"asset\":\"EUR\",\"rpcport\":8065}, {\"coin\":\"GBP\",\"asset\":\"GBP\",\"rpcport\":11505}, {\"coin\":\"HKD\",\"asset\":\"HKD\",\"rpcport\":15409}, {\"coin\":\"HRK\",\"asset\":\"HRK\",\"rpcport\":12617}, {\"coin\":\"HUF\",\"asset\":\"HUF\",\"rpcport\":13699}, {\"coin\":\"IDR\",\"asset\":\"IDR\",\"rpcport\":14459}, {\"coin\":\"ILS\",\"asset\":\"ILS\",\"rpcport\":14638}, {\"coin\":\"INR\",\"asset\":\"INR\",\"rpcport\":10536}, {\"coin\":\"JPY\",\"asset\":\"JPY\",\"rpcport\":13145}, {\"coin\":\"KRW\",\"asset\":\"KRW\",\"rpcport\":14020}, {\"coin\":\"MXN\",\"asset\":\"MXN\",\"rpcport\":13970}, {\"coin\":\"MYR\",\"asset\":\"MYR\",\"rpcport\":10688}, {\"coin\":\"NOK\",\"asset\":\"NOK\",\"rpcport\":11588}, {\"coin\":\"NZD\",\"asset\":\"NZD\",\"rpcport\":10915}, {\"coin\":\"PHP\",\"asset\":\"PHP\",\"rpcport\":11181}, {\"coin\":\"PLN\",\"asset\":\"PLN\",\"rpcport\":13493}, {\"coin\":\"BRL\",\"asset\":\"BRL\",\"rpcport\":9914}, {\"coin\":\"RON\",\"asset\":\"RON\",\"rpcport\":8675}, {\"coin\":\"RUB\",\"asset\":\"RUB\",\"rpcport\":8199}, {\"coin\":\"SEK\",\"asset\":\"SEK\",\"rpcport\":11447}, {\"coin\":\"SGD\",\"asset\":\"SGD\",\"rpcport\":14475}, {\"coin\":\"THB\",\"asset\":\"THB\",\"rpcport\":11847}, {\"coin\":\"TRY\",\"asset\":\"TRY\",\"rpcport\":13924}, {\"coin\":\"USD\",\"asset\":\"USD\",\"rpcport\":13967}, {\"coin\":\"ZAR\",\"asset\":\"ZAR\",\"rpcport\":15160}]" #{\"coin\":\"PIVX\",\"name\":\"pivx\",\"rpcport\":51473,\"pubtype\":30,\"p2shtype\":13,\"wiftype\":212,\"txfee\":10000}, diff --git a/iguana/exchanges/enable b/iguana/exchanges/enable index 86166f790..e5121918a 100755 --- a/iguana/exchanges/enable +++ b/iguana/exchanges/enable @@ -1,8 +1,11 @@ #!/bin/bash source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PIZZA\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"REVS\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTC\"}" +#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTC\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CHIPS\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SUPERNET\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CRYPTO\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DEX\"}" @@ -15,6 +18,7 @@ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"JUMBLR\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"HUSH\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTCH\"}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HUSH\",\"ipaddr\":\"173.212.225.176\",\"port\":50013}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HUSH\",\"ipaddr\":\"173.212.225.176\",\"port\":50013}" #curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTCH\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10020}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTC\",\"ipaddr\":\"node1.komodo.rocks\",\"port\":50001}" diff --git a/iguana/exchanges/getpeersIP b/iguana/exchanges/getpeersIP index 7c532e609..8fd44da30 100755 --- a/iguana/exchanges/getpeersIP +++ b/iguana/exchanges/getpeersIP @@ -1,11 +1,11 @@ #!/bin/bash -curl --url "http://5.9.253.195:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.196:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.197:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.198:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.199:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.200:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.201:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.202:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.203:7783" --data "{\"method\":\"getpeers\"}" -curl --url "http://5.9.253.204:7783" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.195:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.196:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.197:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.198:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.199:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.200:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.201:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.202:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.203:7782" --data "{\"method\":\"getpeers\"}" +curl --url "http://5.9.253.204:7782" --data "{\"method\":\"getpeers\"}" diff --git a/iguana/exchanges/jpg b/iguana/exchanges/jpg new file mode 100755 index 000000000..1809d9aa0 --- /dev/null +++ b/iguana/exchanges/jpg @@ -0,0 +1,3 @@ +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"password\":\"123\",\"ind\":3453,\"userpass\":\"$userpass\",\"method\":\"jpg\",\"srcfile\":\"/root/boost_1_64_0/libs/gil/doc/doxygen/images/monkey_steps.jpg\",\"destfile\":\"dest.jpg\",\"power2\":3,\"data\":\"68656c6c6f20776f726c64\",\"required\":88}" +curl --url "http://127.0.0.1:7783" --data "{\"password\":\"123\",\"userpass\":\"$userpass\",\"method\":\"jpg\",\"srcfile\":\"dest.jpg\",\"power2\":3,\"required\":88}" diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index cdef05e37..db8bc57b7 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -69,11 +69,35 @@ void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveas #endif #endif + #include "LP_nativeDEX.c" +void LP_ports(uint16_t *pullportp,uint16_t *pubportp,uint16_t *busportp,uint16_t netid) +{ + int32_t netmod,netdiv; uint16_t otherports; + *pullportp = *pubportp = *busportp = 0; + if ( netid < 0 ) + netid = 0; + else if ( netid > (65535-40-LP_RPCPORT)/4 ) + { + printf("netid.%d overflow vs max netid.%d 14420?\n",netid,(65535-40-LP_RPCPORT)/4); + exit(-1); + } + if ( netid != 0 ) + { + netmod = (netid % 10); + netdiv = (netid / 10); + otherports = (netdiv * 40) + (LP_RPCPORT + netmod); + } else otherports = LP_RPCPORT; + *pullportp = otherports + 10; + *pubportp = otherports + 20; + *busportp = otherports + 30; + printf("RPCport.%d remoteport.%d, nanoports %d %d %d\n",RPC_port,RPC_port-1,*pullportp,*pubportp,*busportp); +} + void LP_main(void *ptr) { - char *passphrase; double profitmargin; int32_t netmod,netdiv,netid=0; uint16_t port,otherports; cJSON *argjson = ptr; + char *passphrase; double profitmargin; uint16_t netid=0,port,pullport,pubport,busport; cJSON *argjson = ptr; if ( (passphrase= jstr(argjson,"passphrase")) != 0 ) { profitmargin = jdouble(argjson,"profitmargin"); @@ -82,21 +106,8 @@ void LP_main(void *ptr) port = LP_RPCPORT; if ( jobj(argjson,"netid") != 0 ) netid = juint(argjson,"netid"); - if ( netid < 0 ) - netid = 0; - else if ( netid > (65535-40-LP_RPCPORT)/4 ) - { - printf("netid.%d overflow vs max netid.%d 14420?\n",netid,(65535-40-LP_RPCPORT)/4); - exit(-1); - } - if ( netid != 0 ) - { - netmod = (netid % 10); - netdiv = (netid / 10); - otherports = (netdiv * 40) + (LP_RPCPORT + netmod); - } else otherports = LP_RPCPORT; - printf("RPCport.%d remoteport.%d, nanoports %d %d %d\n",port,port-1,otherports+10,otherports+20,otherports+30); - LPinit(port,otherports+10,otherports+20,otherports+30,passphrase,jint(argjson,"client"),jstr(argjson,"userhome"),argjson); + LP_ports(&pullport,&pubport,&busport,netid); + LPinit(port,pullport,pubport,busport,passphrase,jint(argjson,"client"),jstr(argjson,"userhome"),argjson); } } @@ -203,15 +214,17 @@ 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","test"); + 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)); exit(-1); } //else printf("(%s) launched.(%s)\n",argv[1],passphrase); incr = 100.; - while ( (1) ) + while ( LP_STOP_RECEIVED == 0 ) sleep(100000); } #endif diff --git a/iguana/exchanges/prices/autoprice b/iguana/exchanges/prices/autoprice index 4536e16e9..eb3b53851 100755 --- a/iguana/exchanges/prices/autoprice +++ b/iguana/exchanges/prices/autoprice @@ -12,11 +12,13 @@ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTCH\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"HUSH\",\"factor\":1.44,\"buymargin\":0.05,\"sellmargin\":0.05}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTCH\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"HUSH\",\"refrel\":\"KMD\",\"factor\":0.7,\"buymargin\":0.05,\"sellmargin\":0.05}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"PIZZA\",\"fixed\":0.0001,\"margin\":0.00001}" + source crypto source trackbtc -source jumblr -source trackbtc +#source jumblr +#source trackbtc source pangea source trackbtc @@ -24,8 +26,8 @@ source trackbtc source bet source trackbtc -source revs -source trackbtc +#source revs +#source trackbtc sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":145}" curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}" @@ -40,4 +42,8 @@ curl --url "http://127.0.0.1:7783" --data "{\"base\":\"DEX\",\"rel\":\"KMD\",\"m curl --url "http://127.0.0.1:7783" --data "{\"base\":\"BOTS\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNdqHx26GWy9bk8MtmH1UiXjQcXE4RKK2P\",\"holdings\":[$dexholdings],\"divisor\":3333333}" -curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MGW\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"holdings\":[$dexholdings],\"divisor\":10000000}" +curl --url "http://127.0.0.1:7783" --data "{\"base\":\"JUMBLR\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RGhxXpXSSBTBm9EvNsXnTQczthMCxHX91t\",\"holdings\":[$dexholdings],\"divisor\":3333333}" + +curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MGW\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"holdings\":[$dexholdings],\"divisor\":13000000}" + +curl --url "http://127.0.0.1:7783" --data "{\"base\":\"REVS\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"holdings\":[$dexholdings],\"divisor\":9000000}" diff --git a/iguana/exchanges/run b/iguana/exchanges/run index ec549c0c7..0954a5c1a 100755 --- a/iguana/exchanges/run +++ b/iguana/exchanges/run @@ -1,8 +1,9 @@ #!/bin/bash source passphrase source coins -pkill -15 marketmaker; +./stop git pull; cd ..; ./m_mm; +pkill -15 marketmaker; $1 ./marketmaker "{\"gui\":\"nogui\", \"profitmargin\":0.01, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" & diff --git a/iguana/exchanges/setpassphrase b/iguana/exchanges/setpassphrase index eec8bc5b1..ad170a572 100755 --- a/iguana/exchanges/setpassphrase +++ b/iguana/exchanges/setpassphrase @@ -1,3 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"passphrase\",\"passphrase\":\"put the passphrase here\",\"gui\":\"buildog\"}" +source passphrase +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f\",\"method\":\"passphrase\",\"passphrase\":\"$passphrase\",\"gui\":\"nogui\"}" diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index e20bfa284..922e4606e 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -29,6 +29,7 @@ #define STATS_DEST "/var/www/html/DEXstats.json" #include "DEXstats.h" char *stats_JSON(void *ctx,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port); +extern uint32_t DOCKERFLAG; char *stats_validmethods[] = { @@ -46,6 +47,7 @@ int32_t LP_valid_remotemethod(cJSON *argjson) for (i=0; i 0 ) { jsonflag = postflag = 0; - portable_mutex_lock(&LP_commandmutex); + //portable_mutex_lock(&LP_commandmutex); retstr = stats_rpcparse(space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype,req->port); - portable_mutex_unlock(&LP_commandmutex); + //portable_mutex_unlock(&LP_commandmutex); if ( filetype[0] != 0 ) { static cJSON *mimejson; char *tmp,*typestr=0; long tmpsize; @@ -771,7 +773,7 @@ void LP_rpc_processreq(void *_ptr) spawned--; } -extern int32_t IAMLP; +extern int32_t IAMLP,LP_STOP_RECEIVED; //int32_t LP_bindsock_reset,LP_bindsock = -1; void stats_rpcloop(void *args) @@ -782,7 +784,7 @@ void stats_rpcloop(void *args) printf("Start stats_rpcloop.%u\n",port); localhostbits = (uint32_t)calc_ipbits("127.0.0.1"); //initial_bindsock_reset = LP_bindsock_reset; - while ( 1 )//LP_bindsock_reset == initial_bindsock_reset ) + while ( LP_STOP_RECEIVED == 0 )//LP_bindsock_reset == initial_bindsock_reset ) { //printf("LP_bindsock.%d\n",LP_bindsock); if ( bindsock < 0 ) @@ -817,6 +819,7 @@ void stats_rpcloop(void *args) } #endif*/ memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits)); +//printf("port.%u got incoming from %x\n",port,ipbits); if ( DOCKERFLAG != 0 && (DOCKERFLAG == 1 || ipbits == DOCKERFLAG) ) ipbits = localhostbits; if ( port == RPC_port && ipbits != localhostbits ) @@ -858,7 +861,7 @@ continue; #ifndef FROM_MARKETMAKER portable_mutex_t LP_commandmutex; -uint16_t LP_RPCPORT; +uint16_t LP_RPCPORT = 7763; void stats_kvjson(FILE *logfp,int32_t height,int32_t savedheight,uint32_t timestamp,char *key,cJSON *kvjson,bits256 pubkey,bits256 sigprev) { @@ -1196,7 +1199,7 @@ int main(int argc, const char * argv[]) exit(-1); } printf("DEX stats running\n"); - while ( 1 ) + while ( LP_STOP_RECEIVED == 0 ) { if ( (filestr= stats_update(logfp,STATS_DEST,statefname,komodofile)) != 0 ) { diff --git a/iguana/exchanges/status b/iguana/exchanges/status index 0499bba6b..9f89cb314 100755 --- a/iguana/exchanges/status +++ b/iguana/exchanges/status @@ -1,3 +1,3 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"swapstatus\"}" +curl --url "http://127.0.0.1:7783" --data "{\"pending\":1,\"userpass\":\"$userpass\",\"method\":\"swapstatus\"}" diff --git a/iguana/m_mm b/iguana/m_mm index b5c033488..5a227a69a 100755 --- a/iguana/m_mm +++ b/iguana/m_mm @@ -1,3 +1,3 @@ cd secp256k1; ./m_unix; cd .. cd ../crypto777; ./m_LP; cd ../iguana -gcc -g -o marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a -lnanomsg -lcurl -lpthread -lm +gcc -g -o marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a -lnanomsg -lcurl -lpthread -lm diff --git a/iguana/m_mm_StaticNanoMsg b/iguana/m_mm_StaticNanoMsg index cab8ae51b..2c224b764 100755 --- a/iguana/m_mm_StaticNanoMsg +++ b/iguana/m_mm_StaticNanoMsg @@ -19,10 +19,9 @@ all: +$(MAKE) -C secp256k1 -f m_unix_Makefile all +$(MAKE) -C ../crypto777 -f m_LP_StaticNanoMsg all +$(MAKE) -C ../crypto777 -f m_LP_StaticNanoMsg clean - $(CC) -o ../agents/marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c secp256k1.o ../agents/libcrypto777.a ../OSlibs/linux/$(shell uname -m)/libnanomsg-static.a -lcurl -lpthread -lm -lanl + $(CC) -o ../agents/marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a ../OSlibs/linux/$(shell uname -m)/libnanomsg-static.a -lcurl -lpthread -lm -lanl @echo "===========================" @echo " marketmaker -> `pwd`/../agents/marketmaker" @echo "===========================" - diff --git a/marketmaker.vcxproj b/marketmaker.vcxproj index 26e11409a..fbe023dc8 100644 --- a/marketmaker.vcxproj +++ b/marketmaker.vcxproj @@ -248,6 +248,7 @@ + diff --git a/marketmaker.vcxproj.filters b/marketmaker.vcxproj.filters index 59cf37d99..36d2bdfe0 100644 --- a/marketmaker.vcxproj.filters +++ b/marketmaker.vcxproj.filters @@ -293,6 +293,9 @@ Source Files + + Source Files +