Browse Source

Test

etomic
jl777 7 years ago
parent
commit
8ba76912c5
  1. 22
      iguana/exchanges/LP_coins.c
  2. 2
      iguana/exchanges/LP_commands.c
  3. 2
      iguana/exchanges/LP_include.h
  4. 2
      iguana/exchanges/LP_utxos.c
  5. 3
      iguana/exchanges/client

22
iguana/exchanges/LP_coins.c

@ -145,11 +145,17 @@ cJSON *LP_coinjson(struct iguana_info *coin)
{ {
cJSON *item = cJSON_CreateObject(); cJSON *item = cJSON_CreateObject();
jaddstr(item,"coin",coin->symbol); jaddstr(item,"coin",coin->symbol);
if ( coin->inactive != 0 )
jaddstr(item,"status","inactive");
if ( coin->isPoS != 0 )
jaddstr(item,"type","PoS");
jaddstr(item,"smartaddress",coin->smartaddr); jaddstr(item,"smartaddress",coin->smartaddr);
jaddstr(item,"rpc",coin->serverport); jaddstr(item,"rpc",coin->serverport);
jaddnum(item,"pubtype",coin->pubtype); jaddnum(item,"pubtype",coin->pubtype);
jaddnum(item,"p2shtype",coin->p2shtype); jaddnum(item,"p2shtype",coin->p2shtype);
jaddnum(item,"wiftype",coin->wiftype); jaddnum(item,"wiftype",coin->wiftype);
jaddnum(item,"estimatedrate",coin->estimatedrate);
jaddnum(item,"txfee",coin->txfee);
return(item); return(item);
} }
@ -162,11 +168,12 @@ cJSON *LP_coinsjson()
return(array); return(array);
} }
void LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain) void LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain)
{ {
memset(coin,0,sizeof(*coin)); memset(coin,0,sizeof(*coin));
safecopy(coin->symbol,symbol,sizeof(coin->symbol)); safecopy(coin->symbol,symbol,sizeof(coin->symbol));
sprintf(coin->serverport,"127.0.0.1:%u",port); sprintf(coin->serverport,"127.0.0.1:%u",port);
coin->isPoS = isPoS;
coin->longestchain = longestchain; coin->longestchain = longestchain;
coin->txfee = txfee; coin->txfee = txfee;
coin->estimatedrate = estimatedrate; coin->estimatedrate = estimatedrate;
@ -198,11 +205,12 @@ struct iguana_info *LP_coinsearch(char *symbol)
struct iguana_info *LP_coinfind(char *symbol) struct iguana_info *LP_coinfind(char *symbol)
{ {
struct iguana_info *coin,cdata; int32_t longestchain = 1000000; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name,*assetname; struct iguana_info *coin,cdata; int32_t isPoS,longestchain = 1000000; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name,*assetname;
if ( (coin= LP_coinsearch(symbol)) != 0 ) if ( (coin= LP_coinsearch(symbol)) != 0 )
return(coin); return(coin);
if ( (port= LP_rpcport(symbol)) == 0 ) if ( (port= LP_rpcport(symbol)) == 0 )
return(0); return(0);
isPoS = 0;
txfee = 10000; txfee = 10000;
estimatedrate = 20; estimatedrate = 20;
pubtype = 60; pubtype = 60;
@ -225,7 +233,7 @@ struct iguana_info *LP_coinfind(char *symbol)
name = symbol; name = symbol;
assetname = symbol; assetname = symbol;
} }
LP_coininit(&cdata,symbol,name,assetname,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain); LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain);
return(LP_coinadd(&cdata)); return(LP_coinadd(&cdata));
} }
@ -233,9 +241,10 @@ struct iguana_info *LP_coinfind(char *symbol)
struct iguana_info *LP_coincreate(cJSON *item) struct iguana_info *LP_coincreate(cJSON *item)
{ {
struct iguana_info cdata; int32_t longestchain = 1000000; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name,*symbol,*assetname; struct iguana_info cdata,*coin; int32_t isPoS,longestchain = 1000000; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name,*symbol,*assetname;
if ( (symbol= jstr(item,"coin")) != 0 && symbol[0] != 0 && strlen(symbol) < 16 && LP_coinfind(symbol) == 0 && (port= juint(item,"rpcport")) != 0 ) if ( (symbol= jstr(item,"coin")) != 0 && symbol[0] != 0 && strlen(symbol) < 16 && LP_coinfind(symbol) == 0 && (port= juint(item,"rpcport")) != 0 )
{ {
isPoS = jint(item,"isPoS");
if ( (txfee= j64bits(item,"txfee")) == 0 ) if ( (txfee= j64bits(item,"txfee")) == 0 )
txfee = 10000; txfee = 10000;
if ( (estimatedrate= jdouble(item,"estimatedrate")) == 0. ) if ( (estimatedrate= jdouble(item,"estimatedrate")) == 0. )
@ -250,8 +259,9 @@ struct iguana_info *LP_coincreate(cJSON *item)
name = assetname; name = assetname;
else if ( (name= jstr(item,"name")) == 0 ) else if ( (name= jstr(item,"name")) == 0 )
name = symbol; name = symbol;
LP_coininit(&cdata,symbol,name,assetname==0?"":assetname,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain); LP_coininit(&cdata,symbol,name,assetname==0?"":assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain);
return(LP_coinadd(&cdata)); if ( (coin= LP_coinadd(&cdata)) != 0 )
coin->inactive = jint(item,"inactive");
} }
return(0); return(0);
} }

2
iguana/exchanges/LP_commands.c

@ -314,6 +314,8 @@ char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port
retstr = LP_connected(argjson); retstr = LP_connected(argjson);
else if ( strcmp(method,"checktxid") == 0 ) else if ( strcmp(method,"checktxid") == 0 )
retstr = LP_spentcheck(argjson); retstr = LP_spentcheck(argjson);
else if ( strcmp(method,"getcoins") == 0 )
retstr = jprint(LP_coinsjson(),1);
else if ( strcmp(method,"getprice") == 0 ) else if ( strcmp(method,"getprice") == 0 )
retstr = LP_pricestr(jstr(argjson,"base"),jstr(argjson,"rel")); retstr = LP_pricestr(jstr(argjson,"base"),jstr(argjson,"rel"));
else if ( strcmp(method,"orderbook") == 0 ) else if ( strcmp(method,"orderbook") == 0 )

2
iguana/exchanges/LP_include.h

@ -140,7 +140,7 @@ struct basilisk_swapinfo
struct iguana_info struct iguana_info
{ {
uint64_t txfee; double estimatedrate; uint64_t txfee; double estimatedrate;
int32_t longestchain; uint32_t counter; int32_t longestchain; uint32_t counter,inactive;
uint8_t pubtype,p2shtype,isPoS,wiftype; uint8_t pubtype,p2shtype,isPoS,wiftype;
char symbol[16],smartaddr[64],userpass[1024],serverport[128]; char symbol[16],smartaddr[64],userpass[1024],serverport[128];
}; };

2
iguana/exchanges/LP_utxos.c

@ -411,7 +411,7 @@ uint64_t LP_privkey_init(struct LP_peerinfo *mypeer,int32_t mypubsock,char *symb
} }
bitcoin_addr2rmd160(&tmptype,rmd160,coin->smartaddr); bitcoin_addr2rmd160(&tmptype,rmd160,coin->smartaddr);
LP_privkeyadd(privkey,rmd160); LP_privkeyadd(privkey,rmd160);
if ( (array= LP_listunspent(symbol,coin->smartaddr)) != 0 ) if ( coin->inactive == 0 && (array= LP_listunspent(symbol,coin->smartaddr)) != 0 )
{ {
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{ {

3
iguana/exchanges/client

@ -3,5 +3,4 @@ pkill -15 marketmaker;
git pull; git pull;
cd ..; cd ..;
./m_mm; ./m_mm;
#./marketmaker "{\"client\":1,\"coins\":[{\"coin\":\"REVS\", \"asset\":\"REVS\", \"rpcport\":10196}, {\"coin\":\"JUMBLR\", \"asset\":\"JUMBLR\", \"rpcport\":15106}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }], \"userhome\":\"/${HOME#"/"}\",\"passphrase\":\"$randval\"}" & ./marketmaker "{\"client\":1,\"coins\":[{\"coin\":\"REVS\", \"asset\":\"REVS\", \"rpcport\":10196}, {\"coin\":\"JUMBLR\", \"asset\":\"JUMBLR\", \"rpcport\":15106}, {\"coin\":\"LTC\", \"inactive\":1, \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }], \"userhome\":\"/${HOME#"/"}\",\"passphrase\":\"$randval\"}" &
./marketmaker "{\"client\":1,\"coins\":[{\"coin\":\"REVS\", \"asset\":\"REVS\", \"rpcport\":10196}, {\"coin\":\"JUMBLR\", \"asset\":\"JUMBLR\", \"rpcport\":15106}], \"userhome\":\"/${HOME#"/"}\",\"passphrase\":\"$randval\"}" &

Loading…
Cancel
Save