Browse Source

Merge pull request #739 from jl777/dev

reduce notarizing txfee, among many other changes
patch-1
jl777 7 years ago
committed by GitHub
parent
commit
ba557bf83d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .gitignore
  2. 30
      .travis.yml
  3. 2
      CMakeLists.txt
  4. 2
      cpp-ethereum
  5. 4
      iguana/dPoW.h
  6. 2
      iguana/dpow/dpow_rpc.c
  7. 2
      iguana/dpow/dpow_tx.c
  8. 8
      iguana/exchanges/CMakeLists.txt
  9. 2
      iguana/exchanges/DEXstats.h
  10. 34
      iguana/exchanges/LP_commands.c
  11. 3
      iguana/exchanges/LP_include.h
  12. 6
      iguana/exchanges/LP_instantdex.c
  13. 4
      iguana/exchanges/LP_nativeDEX.c
  14. 3
      iguana/exchanges/LP_network.c
  15. 17
      iguana/exchanges/LP_ordermatch.c
  16. 79
      iguana/exchanges/LP_portfolio.c
  17. 3
      iguana/exchanges/LP_prices.c
  18. 2
      iguana/exchanges/LP_remember.c
  19. 33
      iguana/exchanges/LP_rpc.c
  20. 4
      iguana/exchanges/LP_utxo.c
  21. 2
      iguana/exchanges/auto_usd
  22. 2
      iguana/exchanges/coins
  23. 6
      iguana/exchanges/fasttest
  24. 3
      iguana/exchanges/getfee
  25. 3
      iguana/exchanges/listtransactions
  26. 2
      iguana/exchanges/mm.c
  27. 8
      iguana/exchanges/run_osx
  28. 48
      iguana/exchanges/stats.c
  29. 2
      marketmaker_build_depends.cmd

3
.gitignore

@ -259,3 +259,6 @@ build
.idea
Release/*
build_win64_release/*
DB/*

30
.travis.yml

@ -0,0 +1,30 @@
language: c
matrix:
include:
- os: linux
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env: OS_NAME=Linux MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
- os: osx
compiler: clang
env: OS_NAME=Darwin
osx_image: xcode9.2
before_install:
- git submodule update --init --recursive
script:
- mkdir build && cd build
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake ..; fi
- cmake --build . --target marketmaker-mainnet
cache:
directories:
- $HOME/.hunter

2
CMakeLists.txt

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9.6)
cmake_minimum_required(VERSION 3.9.2)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.19.173.tar.gz"

2
cpp-ethereum

@ -1 +1 @@
Subproject commit 633c62c08bc73c7c3935c948a8d6c656a3659976
Subproject commit c25a98257e7104875503e183dd0f27d49b3efd56

4
iguana/dPoW.h

@ -23,8 +23,8 @@
#define DPOW_MIN_ASSETCHAIN_SIGS 11
//#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1)
#define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries)
#define DPOW_VERSION 0x1781
#define DPOW_UTXOSIZE 50000
#define DPOW_VERSION 0x1782
#define DPOW_UTXOSIZE 10000//50000
#define DPOW_MINOUTPUT 6000
#define DPOW_DURATION 600
#define DPOW_RATIFYDURATION (3600 * 24)

2
iguana/dpow/dpow_rpc.c

@ -230,7 +230,7 @@ int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp,bits256 MoM,uint32_t Mo
{
struct iguana_info *coin; char *retstr,*hexstr; cJSON *retjson; int32_t n=0; uint32_t paxwdcrc;
paxwdcrc = 0;
if ( Notaries_port != DPOW_SOCKPORT )
//if ( Notaries_port != DPOW_SOCKPORT )
{
n += iguana_rwbignum(1,&hex[n],sizeof(MoM),MoM.bytes);
n += iguana_rwnum(1,&hex[n],sizeof(MoMdepth),(uint32_t *)&MoMdepth);

2
iguana/dpow/dpow_tx.c

@ -232,7 +232,7 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in
printf("%02x",extras[i]);
printf(" <- withdraw.%d %08x\n",n,paxwdcrc);
}
else if ( Notaries_port != DPOW_SOCKPORT && bp->MoMdepth > 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) // only testnets for now
else if ( bp->MoMdepth > 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) // Notaries_port != DPOW_SOCKPORT &&
{
n = dpow_paxpending(extras,&paxwdcrc,bp->MoM,bp->MoMdepth);
//n += iguana_rwbignum(1,&extras[n],sizeof(bp->MoM),bp->MoM.bytes);

8
iguana/exchanges/CMakeLists.txt

@ -26,5 +26,9 @@ add_definitions(-DIGUANA_MAXPACKETSIZE=1572864)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
include_directories("${CMAKE_SOURCE_DIR}/includes")
endif()
target_link_libraries(marketmaker-testnet ${MM_LIBS} etomiclib-testnet -static-libgcc -static-libstdc++)
target_link_libraries(marketmaker-mainnet ${MM_LIBS} etomiclib-mainnet -static-libgcc -static-libstdc++)
target_link_libraries(marketmaker-testnet ${MM_LIBS} etomiclib-testnet)
target_link_libraries(marketmaker-mainnet ${MM_LIBS} etomiclib-mainnet)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(marketmaker-mainnet -static-libgcc -static-libstdc++)
target_link_libraries(marketmaker-testnet -static-libgcc -static-libstdc++)
endif()

2
iguana/exchanges/DEXstats.h

@ -928,7 +928,7 @@ char *stats_prices(char *symbol,char *dest,struct DEXstats_disp *prices,int32_t
#ifndef FROM_MARKETMAKER
#ifndef FROM_PRIVATEBET
char *stats_JSON(void *ctx,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port)
char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port)
{
char *method,*agent,*retstr,*source,*dest; struct tai T; uint32_t endtimestamp; struct DEXstats_disp prices[365]; int32_t leftdatenum,seconds,numdates;
if ( (method= jstr(argjson,"method")) == 0 )

34
iguana/exchanges/LP_commands.c

@ -32,7 +32,7 @@ char *LP_numutxos()
return(jprint(retjson,1));
}
char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port
char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port
{
char *method,*userpass,*base,*rel,*coin,*passphrase,*retstr = 0; int32_t authenticated=0,changed,flag = 0; cJSON *retjson,*reqjson = 0; struct iguana_info *ptr;
method = jstr(argjson,"method");
@ -168,10 +168,12 @@ timelock(coin, duration, destaddr=(tradeaddr), amount)\n\
unlockedspend(coin, txid)\n\
opreturndecrypt(coin, txid, passphrase)\n\
getendpoint(port=5555)\n\
getfee(coin)\n\
sleep(seconds=60)\n\
listtransactions(coin, address, count=10, skip=0)\n\
jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
\"}"));
//sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\
if ( (base= jstr(argjson,"base")) == 0 )
base = "";
if ((rel= jstr(argjson,"rel")) == 0 )
@ -317,6 +319,13 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
LP_millistats_update(0);
return(clonestr("{\"result\":\"success\"}"));
}
else if ( strcmp(method,"sleep") == 0 )
{
if ( jint(argjson,"seconds") == 0 )
sleep(60);
else sleep(jint(argjson,"seconds"));
return(clonestr("{\"result\":\"success\",\"status\":\"feeling good after sleeping\"}"));
}
else if ( strcmp(method,"getprices") == 0 )
return(LP_prices());
else if ( strcmp(method,"getpeers") == 0 )
@ -584,6 +593,19 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
return(jprint(LP_address_balance(ptr,jstr(argjson,"address"),1),1));
else return(clonestr("{\"error\":\"cant find coind\"}"));
}
else if ( strcmp(method,"getfee") == 0 )
{
uint64_t txfee;
if ( (ptr= LP_coinsearch(coin)) != 0 )
{
txfee = LP_txfeecalc(ptr,0,0);
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddstr(retjson,"coin",coin);
jaddnum(retjson,"txfee",dstr(txfee));
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"cant find coind\"}"));
}
else if ( strcmp(method,"electrum") == 0 )
{
if ( (ptr= LP_coinsearch(coin)) != 0 )
@ -612,6 +634,12 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
{
return(LP_unlockedspend(ctx,coin,jbits256(argjson,"txid")));
}
// cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t skip)
else if ( strcmp(method,"listtransactions") == 0 )
{
if ( (ptr= LP_coinfind(coin)) != 0 )
return(jprint(LP_listtransactions(coin,jstr(argjson,"address"),juint(argjson,"count"),juint(argjson,"skip")),1));
}
else if ( strcmp(method,"getrawtransaction") == 0 )
{
return(jprint(LP_gettx("stats_JSON",coin,jbits256(argjson,"txid"),0),1));

3
iguana/exchanges/LP_include.h

@ -35,7 +35,7 @@ voind dontprintf(char *formatstr,...) {}
#define LP_MAJOR_VERSION "0"
#define LP_MINOR_VERSION "1"
#define LP_BUILD_NUMBER "27771"
#define LP_BUILD_NUMBER "27772"
#define LP_BARTERDEX_VERSION 1
#define LP_MAGICBITS 1
@ -556,6 +556,7 @@ uint16_t LP_randpeer(char *destip);
void LP_tradebot_pauseall();
int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]);
void LP_portfolio_reset();
int32_t LP_autoref_clear(char *base,char *rel);
int32_t bitcoin_addr2rmd160(char *symbol,uint8_t taddr,uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr);
struct LP_pubkey_info *LP_pubkeyadd(bits256 pubkey);
uint32_t LP_atomic_locktime(char *base,char *rel);

6
iguana/exchanges/LP_instantdex.c

@ -678,13 +678,13 @@ cJSON *LP_swapstats_item(struct LP_swapstats *sp,int32_t iambob)
struct iguana_info *bob,*alice; int32_t flag = 0; char *retstr,*swapstr; bits256 zero; cJSON *item,*reqjson,*swapjson;
item = cJSON_CreateObject();
jaddnum(item,"iambob",iambob);
jaddnum(item,"aliceid",sp->aliceid);
jadd64bits(item,"aliceid",sp->aliceid);
jaddnum(item,"requestid",sp->Q.R.requestid);
jaddnum(item,"quoteid",sp->Q.R.quoteid);
jaddstr(item,"base",sp->Q.srccoin);
jaddnum(item,"satoshis",sp->Q.satoshis);
jadd64bits(item,"satoshis",sp->Q.satoshis);
jaddstr(item,"rel",sp->Q.destcoin);
jaddnum(item,"destsatoshis",sp->Q.destsatoshis);
jadd64bits(item,"destsatoshis",sp->Q.destsatoshis);
jaddnum(item,"price",sp->Q.destsatoshis/((double)sp->Q.satoshis+1));
if ( LP_swap_finished(sp,1) == 0 )
{

4
iguana/exchanges/LP_nativeDEX.c

@ -204,7 +204,7 @@ char *LP_command_process(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson
return(0);
if ( stats_JSONonly != 0 || LP_tradecommand(ctx,myipaddr,pubsock,argjson,data,datalen) <= 0 )
{
if ( (retstr= stats_JSON(ctx,myipaddr,pubsock,argjson,"127.0.0.1",stats_JSONonly)) != 0 )
if ( (retstr= stats_JSON(ctx,0,myipaddr,pubsock,argjson,"127.0.0.1",stats_JSONonly)) != 0 )
{
//printf("%s PULL.[%d]-> (%s)\n",myipaddr != 0 ? myipaddr : "127.0.0.1",datalen,retstr);
//if ( pubsock >= 0 ) //strncmp("{\"error\":",retstr,strlen("{\"error\":")) != 0 &&
@ -425,7 +425,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int
//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 )
if ( (retstr= stats_JSON(ctx,0,myipaddr,pubsock,argjson,remoteaddr,0)) != 0 )
free(retstr);
}
//portable_mutex_unlock(&LP_commandmutex);

3
iguana/exchanges/LP_network.c

@ -445,7 +445,7 @@ void LP_commandQ_loop(void *ctx)
portable_mutex_unlock(&LP_commandQmutex);
if ( ptr->stats_JSONonly < 0 ) // broadcast passthrough
{
if ( 1 && ptr->responsesock >= 0 )
if ( ptr->responsesock >= 0 )
{
if ( (result= cJSON_Parse(ptr->msg)) != 0 )
{
@ -461,6 +461,7 @@ void LP_commandQ_loop(void *ctx)
}
else if ( (argjson= cJSON_Parse(ptr->msg)) != 0 )
{
//printf("deQ.(%s)\n",jprint(argjson,0));
if ( (retstr= LP_command_process(ctx,"127.0.0.1",ptr->responsesock,argjson,(uint8_t *)ptr->msg,ptr->msglen,ptr->stats_JSONonly)) != 0 )
{
if ( ptr->retstrp != 0 )

17
iguana/exchanges/LP_ordermatch.c

@ -1483,15 +1483,20 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha
jaddnum(retjson,"wait",Alice_expiration-time(NULL));
return(jprint(retjson,1));
} else LP_alicequery_clear();
LP_address_utxo_reset(&num,relcoin);
if ( num <= 1 )
if ( relcoin->etomic[0] != 0 )
LP_address_utxo_reset(&num,LP_coinfind("ETOMIC"));
else
{
if ( time(NULL) > relcoin->lastautosplit+300 )
LP_address_utxo_reset(&num,relcoin);
if ( num <= 1 )
{
relcoin->lastautosplit = (uint32_t)time(NULL);
return(LP_autosplit(relcoin));
if ( time(NULL) > relcoin->lastautosplit+300 )
{
relcoin->lastautosplit = (uint32_t)time(NULL);
return(LP_autosplit(relcoin));
}
return(clonestr("{\"error\":\"not enough utxo, please make more deposits\"}"));
}
return(clonestr("{\"error\":\"not enough utxo, please make more deposits\"}"));
}
LP_txfees(&txfee,&desttxfee,base,rel);
if ( txfee != 0 && txfee < 10000 )

79
iguana/exchanges/LP_portfolio.c

@ -22,7 +22,7 @@ struct LP_portfoliotrade { double metric; char buycoin[65],sellcoin[65]; };
struct LP_autoprice_ref
{
char refbase[65],refrel[65],base[65],rel[65],fundbid[16],fundask[16];
char refbase[65],refrel[65],base[65],rel[65],fundbid[16],fundask[16],usdpeg;
double buymargin,sellmargin,factor,offset,lastbid,lastask;
cJSON *fundvalue;
uint32_t count;
@ -455,6 +455,21 @@ double LP_tickered_price(int32_t bidask,char *base,char *rel,double price,cJSON
return(price);
}
int32_t LP_autoref_clear(char *base,char *rel)
{
int32_t i;
for (i=0; i<num_LP_autorefs; i++)
{
if ( (strcmp(rel,LP_autorefs[i].rel) == 0 && strcmp(base,LP_autorefs[i].base) == 0) ||
(strcmp(base,LP_autorefs[i].rel) == 0 && strcmp(rel,LP_autorefs[i].base) == 0) )
{
memset(&LP_autorefs[i],0,sizeof(LP_autorefs[i]));
return(i);
}
}
return(-1);
}
void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
{
static cJSON *tickerjson; static uint32_t lasttime;
@ -463,19 +478,25 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
if ( (retstr= issue_curlt("https://bittrex.com/api/v1.1/public/getmarketsummaries",LP_HTTP_TIMEOUT*10)) == 0 )
{
printf("trex error getting marketsummaries\n");
sleep(60);
return;
sleep(40);
//return;
}
else
{
nxtkmd = LP_pricesparse(ctx,1,retstr,btcpp);
free(retstr);
}
nxtkmd = LP_pricesparse(ctx,1,retstr,btcpp);
free(retstr);
if ( (retstr= issue_curlt("https://www.cryptopia.co.nz/api/GetMarkets",LP_HTTP_TIMEOUT*10)) == 0 )
{
printf("cryptopia error getting marketsummaries\n");
sleep(60);
return;
sleep(40);
//return;
}
else
{
LP_pricesparse(ctx,0,retstr,btcpp);
free(retstr);
}
LP_pricesparse(ctx,0,retstr,btcpp);
free(retstr);
if ( (kmdpp= LP_priceinfofind("KMD")) != 0 )
{
for (i=0; i<32; i++)
@ -534,6 +555,8 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
{
rel = LP_autorefs[i].rel;
base = LP_autorefs[i].base;
if ( rel[0] == 0 || base[0] == 0 )
continue;
buymargin = LP_autorefs[i].buymargin;
sellmargin = LP_autorefs[i].sellmargin;
offset = LP_autorefs[i].offset;
@ -574,15 +597,27 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
//printf("%s/%s for %s/%s margin %.8f/%.8f\n",base,rel,LP_autorefs[i].refbase,LP_autorefs[i].refrel,buymargin,sellmargin);
if ( (price_btc= LP_CMCbtcprice(&price_usd,LP_autorefs[i].refbase)) > SMALLVAL )
{
if ( strcmp(rel,"KMD") == 0 && kmd_btc > SMALLVAL )
price = kmd_btc / price_btc;
else if ( strcmp(rel,"BCH") == 0 && bch_btc > SMALLVAL )
price = bch_btc / price_btc;
else if ( strcmp(rel,"BTC") == 0 )
price = 1. / price_btc;
else continue;
if ( LP_autorefs[i].usdpeg != 0 )
{
if ( price_usd > SMALLVAL )
price = 1. / price_usd;
else continue;
}
else
{
if ( strcmp(rel,"KMD") == 0 && kmd_btc > SMALLVAL )
price = kmd_btc / price_btc;
else if ( strcmp(rel,"BCH") == 0 && bch_btc > SMALLVAL )
price = bch_btc / price_btc;
else if ( strcmp(rel,"BTC") == 0 )
price = 1. / price_btc;
else continue;
}
if ( factor > 0. )
{
//printf("USD %.8f KMDBTC %.8f pricebtc %.8f price %.8f -> factor %.8f %.8f\n",price_usd,kmd_btc,price_btc,price,factor,(price * factor) + offset);
price = (price * factor) + offset;
}
newprice = (price * (1. + buymargin));
if ( LP_autorefs[i].lastbid < SMALLVAL )
LP_autorefs[i].lastbid = newprice;
@ -598,7 +633,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
newprice = LP_autorefs[i].lastask;
LP_mypriceset(&changed,base,rel,newprice);
LP_pricepings(ctx,LP_myipaddr,LP_mypubsock,base,rel,newprice);
}
} //else printf("null return from CMC\n");
}
else
{
@ -719,8 +754,9 @@ int32_t LP_autoprice(void *ctx,char *base,char *rel,cJSON *argjson)
safecopy(LP_autorefs[num_LP_autorefs].fundbid,fundvalue_bid,sizeof(LP_autorefs[num_LP_autorefs].fundbid));
safecopy(LP_autorefs[num_LP_autorefs].fundask,fundvalue_ask,sizeof(LP_autorefs[num_LP_autorefs].fundask));
}
LP_autorefs[i].buymargin = buymargin;
LP_autorefs[i].sellmargin = sellmargin;
LP_autorefs[num_LP_autorefs].usdpeg = juint(argjson,"usdpeg");
LP_autorefs[num_LP_autorefs].buymargin = buymargin;
LP_autorefs[num_LP_autorefs].sellmargin = sellmargin;
LP_autorefs[num_LP_autorefs].factor = factor;
LP_autorefs[num_LP_autorefs].offset = offset;
safecopy(LP_autorefs[num_LP_autorefs].refbase,refbase,sizeof(LP_autorefs[num_LP_autorefs].refbase));
@ -858,14 +894,15 @@ 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 = 600000.;
printf("start prices_loop\n");
while ( LP_STOP_RECEIVED == 0 )
{
//printf("G.initializing.%d prices loop autoprices.%d autorefs.%d\n",G.initializing,LP_autoprices,num_LP_autorefs);
if ( G.initializing != 0 )
{
sleep(1);
sleep(30);
continue;
}
//printf("prices loop autoprices.%d autorefs.%d\n",LP_autoprices,num_LP_autorefs);
LP_millistats_update(&prices_loop_stats);
LP_tradebots_timeslice(ctx);
if ( (btcpp= LP_priceinfofind("BTC")) == 0 )

3
iguana/exchanges/LP_prices.c

@ -532,6 +532,7 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price)
relpp->sellmargins[basepp->ind] = 0.;
relpp->offsets[basepp->ind] = 0.;
relpp->factors[basepp->ind] = 0.;
LP_autoref_clear(base,rel);
margin = 0.;
}
else if ( (minprice= basepp->minprices[relpp->ind]) > SMALLVAL && price < minprice )
@ -1230,7 +1231,7 @@ double LP_CMCbtcprice(double *price_usdp,char *symbol)
item = jitem(ticker,0);
price_btc = jdouble(item,"price_btc");
*price_usdp = jdouble(item,"price_usd");
//printf("%.8f item.(%s)\n",price_btc,jprint(item,0));
//printf("%.8f item.(%s)\n",price_btc,jprint(item,0));
free_json(ticker);
}
free(retstr);

2
iguana/exchanges/LP_remember.c

@ -1772,7 +1772,7 @@ char *LP_recent_swaps(int32_t limit)
jaddstr(item,"alice",LP_Alicequery.destcoin);
jaddstr(item,"rel",LP_Alicequery.destcoin);
jaddnum(item,"relvalue",dstr(LP_Alicequery.destsatoshis));
jaddnum(item,"aliceid",LP_aliceid_calc(LP_Alicequery.desttxid,LP_Alicequery.destvout,LP_Alicequery.feetxid,LP_Alicequery.feevout));
jadd64bits(item,"aliceid",LP_aliceid_calc(LP_Alicequery.desttxid,LP_Alicequery.destvout,LP_Alicequery.feetxid,LP_Alicequery.feevout));
jadd(retjson,"pending",item);
} else Alice_expiration = 0;
return(jprint(retjson,1));

33
iguana/exchanges/LP_rpc.c

@ -495,6 +495,39 @@ cJSON *LP_listreceivedbyaddress(char *symbol,char *coinaddr)
} else return(electrum_address_gethistory(symbol,coin->electrum,&retjson,coinaddr,zero));
}
cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t skip)
{
char buf[128],*addr; bits256 zero; cJSON *retjson,*array,*item; int32_t i,n; struct iguana_info *coin;
if ( symbol == 0 || symbol[0] == 0 )
return(cJSON_Parse("{\"error\":\"null symbol\"}"));
coin = LP_coinfind(symbol);
if ( coin == 0 || (IAMLP == 0 && coin->inactive != 0) )
return(cJSON_Parse("{\"error\":\"no coin\"}"));
memset(zero.bytes,0,sizeof(zero));
if ( coin->electrum == 0 )
{
if ( count == 0 )
count = 10;
sprintf(buf,"[\"\", %d, %d, true]",count,skip);
retjson = cJSON_CreateArray();
if ( (array= bitcoin_json(coin,"listtransactions",buf)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
if ( (addr= jstr(item,"address")) != 0 && strcmp(addr,coinaddr) == 0 )
jaddi(retjson,jduplicate(item));
}
}
free_json(array);
}
return(retjson);
} else return(electrum_address_gethistory(symbol,coin->electrum,&retjson,coinaddr,zero));
}
int64_t LP_listunspent_parseitem(struct iguana_info *coin,bits256 *txidp,int32_t *voutp,int32_t *heightp,cJSON *item)
{
int64_t satoshis = 0;

4
iguana/exchanges/LP_utxo.c

@ -519,9 +519,11 @@ int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,str
struct LP_address *LP_address_utxo_reset(int32_t *nump,struct iguana_info *coin)
{
struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,numconfs,m,vout,height; cJSON *array,*item,*txobj; bits256 zero; int64_t value; bits256 txid; uint32_t now;
*nump = 0;
if ( coin == 0 )
return(0);
LP_address(coin,coin->smartaddr);
memset(zero.bytes,0,sizeof(zero));
*nump = 0;
LP_listunspent_issue(coin->symbol,coin->smartaddr,2,zero,zero);
if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 )
{

2
iguana/exchanges/auto_usd

@ -0,0 +1,2 @@
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"OOT\",\"factor\":0.15,\"buymargin\":0.0001,\"sellmargin\":0.2,\"refbase\":\"komodo\",\"refrel\":\"coinmarketcap\",\"usdpeg\":1}"

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

6
iguana/exchanges/fasttest

@ -0,0 +1,6 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"queueid\":1,\"userpass\":\"$userpass\",\"method\":\"sleep\",\"seconds\":10}" &
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"REVS\",\"rel\":\"KMD\"}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"REVS\",\"rel\":\"KMD\"}"
curl --url "http://127.0.0.1:7783" --data "{\"queueid\":2,\"userpass\":\"$userpass\",\"method\":\"getcoin\",\"coin\":\"REVS\",\"rel\":\"KMD\"}"

3
iguana/exchanges/getfee

@ -0,0 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getfee\",\"coin\":\"BTC\"}"

3
iguana/exchanges/listtransactions

@ -0,0 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"listtransactions\",\"coin\":\"CHIPS\",\"address\":\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\"}"

2
iguana/exchanges/mm.c

@ -37,7 +37,7 @@ void PNACL_message(char *arg,...)
uint32_t DOCKERFLAG;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port);
char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port);
#include "stats.c"
void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveask,double highbid,double lowask,double PAXPRICES[32]);

8
iguana/exchanges/run_osx

@ -1,8 +0,0 @@
#!/bin/bash
source passphrase
source coins
pkill -15 marketmaker;
git pull;
cd ..;
./m_mm;
$1 ./marketmaker "{\"gui\":\"nogui\", \"profitmargin\":0.01, \"userhome\":\"/${HOME#"/"}/Library/Application\ Support\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" &

48
iguana/exchanges/stats.c

@ -28,7 +28,7 @@
#define STATS_DESTDIR "/var/www/html"
#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);
char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port);
void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly,uint32_t queueid);
extern uint32_t DOCKERFLAG;
@ -331,6 +331,10 @@ cJSON *SuperNET_urlconv(char *value,int32_t bufsize,char *urlstr)
extern void *bitcoin_ctx();
extern int32_t IPC_ENDPOINT;
extern portable_mutex_t LP_gcmutex,LP_commandmutex;
extern struct rpcrequest_info *LP_garbage_collector;
uint16_t RPC_port;
static int32_t spawned,maxspawned;
char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *postflagp,char *urlstr,char *remoteaddr,char *filetype,uint16_t port)
{
@ -530,7 +534,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
//free(buf);
//while ( retstr == 0 )
// usleep(10000);
if ( (retstr= stats_JSON(ctx,"127.0.0.1",-1,argjson,remoteaddr,port)) != 0 )
if ( (retstr= stats_JSON(ctx,0,"127.0.0.1",-1,argjson,remoteaddr,port)) != 0 )
{
if ( (retitem= cJSON_Parse(retstr)) != 0 )
jaddi(retarray,retitem);
@ -543,7 +547,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
//free(buf);
//while ( retstr == 0 )
// usleep(10000);
if ( (retstr= stats_JSON(ctx,myipaddr,-1,argjson,remoteaddr,port)) != 0 )
if ( (retstr= stats_JSON(ctx,0,myipaddr,-1,argjson,remoteaddr,port)) != 0 )
{
if ( (retitem= cJSON_Parse(retstr)) != 0 )
jaddi(retarray,retitem);
@ -557,7 +561,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
}
else
{
cJSON *arg; char *buf;
cJSON *arg; char *buf,*method; int32_t fastflag;
if ( jstr(argjson,"agent") != 0 && strcmp(jstr(argjson,"agent"),"bitcoinrpc") != 0 && jobj(argjson,"params") != 0 )
{
arg = jobj(argjson,"params");
@ -567,16 +571,24 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
//printf("ARGJSON.(%s)\n",jprint(arg,0));
if ( userpass != 0 && jstr(arg,"userpass") == 0 )
jaddstr(arg,"userpass",userpass);
if ( (fastflag= jint(arg,"fast")) == 0 )
{
if ( (method= jstr(arg,"method")) != 0 && (strcmp(method,"orderbook") == 0 || strcmp(method,"portfolio") == 0) )
fastflag = 1;
}
if ( fastflag == 0 )
portable_mutex_lock(&LP_commandmutex);
#ifdef FROM_MARKETMAKER
if ( strcmp(remoteaddr,"127.0.0.1") == 0 || LP_valid_remotemethod(arg) > 0 )
{
if ( IPC_ENDPOINT >= 0 && (queueid= juint(arg,"queueid")) > 0 )
{
buf = jprint(arg,0);
//printf("Q command\n");
LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid);
free(buf);
retstr = clonestr("{\"result\":\"success\",\"status\":\"queued\"}");
} else retstr = stats_JSON(ctx,"127.0.0.1",-1,arg,remoteaddr,port);
} else retstr = stats_JSON(ctx,jint(arg,"fast"),"127.0.0.1",-1,arg,remoteaddr,port);
} else retstr = clonestr("{\"error\":\"invalid remote method\"}");
#else
if ( IPC_ENDPOINT >= 0 && (queueid= juint(arg,"queueid")) > 0 )
@ -584,8 +596,10 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
buf = jprint(arg,0);
LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid);
free(buf);
} else retstr = stats_JSON(ctx,myipaddr,-1,arg,remoteaddr,port);
} else retstr = stats_JSON(ctx,jint(arg,"fast"),myipaddr,-1,arg,remoteaddr,port);
#endif
if ( fastflag == 0 )
portable_mutex_unlock(&LP_commandmutex);
}
free_json(argjson);
}
@ -625,13 +639,8 @@ int32_t iguana_getheadersize(char *buf,int32_t recvlen)
return(recvlen);
}
uint16_t RPC_port;
extern portable_mutex_t LP_commandmutex,LP_gcmutex;
extern struct rpcrequest_info *LP_garbage_collector;
void LP_rpc_processreq(void *_ptr)
{
static uint32_t spawned,maxspawned;
char filetype[128],content_type[128];
int32_t recvlen,flag,postflag=0,contentlen,remains,sock,numsent,jsonflag=0,hdrsize,len;
char helpname[512],remoteaddr[64],*buf,*retstr,space[8192],space2[32786],*jsonbuf; struct rpcrequest_info *req = _ptr;
@ -641,11 +650,11 @@ void LP_rpc_processreq(void *_ptr)
sock = req->sock;
recvlen = flag = 0;
retstr = 0;
//space = calloc(1,size);
jsonbuf = calloc(1,size);
//printf("alloc jsonbuf.%p\n",jsonbuf);
remains = size-1;
buf = jsonbuf;
if ( spawned < 0 )
spawned = 0;
spawned++;
if ( spawned > maxspawned )
{
@ -708,9 +717,7 @@ void LP_rpc_processreq(void *_ptr)
if ( recvlen > 0 )
{
jsonflag = postflag = 0;
//portable_mutex_lock(&LP_commandmutex);
retstr = stats_rpcparse(space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype,req->port);
//portable_mutex_unlock(&LP_commandmutex);
if ( filetype[0] != 0 )
{
static cJSON *mimejson; char *tmp,*typestr=0; long tmpsize;
@ -795,7 +802,8 @@ void LP_rpc_processreq(void *_ptr)
//printf("free req.%p\n",req);
free(req);
}
spawned--;
if ( spawned > 0 )
spawned--;
}
extern int32_t IAMLP,LP_STOP_RECEIVED;
@ -854,14 +862,14 @@ void stats_rpcloop(void *args)
continue;
}
req = calloc(1,sizeof(*req));
//printf("alloc req.%p\n",req);
//printf("LP_rpc_processreq req.%p\n",req);
req->sock = sock;
req->ipbits = ipbits;
req->port = port;
LP_rpc_processreq(req);
continue;
if ( spawned > 0 )
LP_rpc_processreq(req);
// this might lead to "cant open file errors"
if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 )
else if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 )
{
printf("error launching rpc handler on port %d, retval.%d\n",port,retval);
LP_rpc_processreq(req);

2
marketmaker_build_depends.cmd

@ -75,7 +75,7 @@ cd curl
mkdir build_msvc_2015_win32
mkdir build_msvc_2015_win64
cd build_msvc_2015_win64
cmake -G "Visual Studio 14 2015 Win64" ..
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_USE_WINSSL:BOOL=ON ..
cmake --build . --config Release --target libcurl
rem cmake .. -G"Visual Studio 14 2015 Win64" -DCURL_STATICLIB=ON -DCURL_DISABLE_LDAP=ON -DCURL_STATIC_CRT=ON

Loading…
Cancel
Save