From f2a479a9c39ee021141090d45adb19fef03f730d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 21:44:23 +0200 Subject: [PATCH] Test --- .gitignore | 6 ++++++ basilisk/basilisk_tradebot.c | 6 +++--- basilisk/tradebots_liquidity.c | 4 ++-- iguana/kmd_lookup.h | 19 +++++++++++++++---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index d4442517d..3f5723493 100755 --- a/.gitignore +++ b/.gitignore @@ -141,3 +141,9 @@ iguana/confs/c6faccf6b625bbb826f47b77c3274e985db7b0a47d435f32bea2f7f3724cdd17.ol iguana/marketmaker iguana/secp256k1.o-501dfbfe + +iguana/confs/cc577d22ca76351d495f147b470103392b5f2ab0948e45608623a7d9728e2c6f + +iguana/confs/cc577d22ca76351d495f147b470103392b5f2ab0948e45608623a7d9728e2c6f.old + +iguana/DB/DEX.log diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index c182df5b4..7940a4e94 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -330,9 +330,9 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk aveprice = refprice; if ( fabs(aveprice) < SMALLVAL ) return(0); - printf("avebid %f bidvol %f, aveask %f askvol %f\n",retvals[0],retvals[1],retvals[2],retvals[3]); //retvals[0] = avebid, retvals[1] = bidvol, retvals[2] = aveask, retvals[3] = askvol; destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount; + printf("aveprice %f dest %.8f avebid %f bidvol %f, aveask %f askvol %f\n",aveprice,dstr(destamount),retvals[0],retvals[1],retvals[2],retvals[3]); if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) @@ -343,8 +343,8 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk free(retstr); } // BTC balance 0.00500000 destamount 0.00041951 aveprice 0.00421619 minamount 0.00020000 - printf("%s balance %.8f destamount %.8f aveprice %.8f minamount %.8f\n",list[0].dest,dstr(balance),dstr(destamount),aveprice,dstr(minamount)); - if ( balance > destamount && (int64_t)destamount > 0 && destamount >= maxamount && destamount >= minamount ) + printf("%s balance %.8f destamount %.8f aveprice %.8f maxamount %.8f minamount %.8f\n",list[0].dest,dstr(balance),dstr(destamount),aveprice,dstr(maxamount),dstr(minamount)); + if ( balance > destamount && (int64_t)destamount > 0 && destamount >= minamount ) // max? { metric = 1.; *issueR = list[0]; diff --git a/basilisk/tradebots_liquidity.c b/basilisk/tradebots_liquidity.c index 8ba0b92de..cc38a2369 100755 --- a/basilisk/tradebots_liquidity.c +++ b/basilisk/tradebots_liquidity.c @@ -1010,7 +1010,7 @@ double _default_liquidity_active(struct supernet_info *myinfo,double *refpricep, dir = 1; else if ( strcmp(rel,refli.base) == 0 && strcmp(base,refli.rel) == 0 ) dir = -1; - else dir = 0; + else continue; if ( exchange[0] != 0 && refli.exchange[0] != 0 && strcmp(exchange,refli.exchange) != 0 ) { printf("continue %s %s/%s [%d] dir.%d vs %s %s/%s\n",exchange,base,rel,i,dir,refli.exchange,refli.base,refli.rel); @@ -1164,7 +1164,7 @@ void tradebots_processprices(struct supernet_info *myinfo,struct exchange_info * //printf("reject %s %s/%s\n",exchange,base,rel); return; } - //printf("%s %s/%s bids.%d asks.%d\n",exchange->name,base,rel,numbids,numasks); + printf("%s %s/%s bids.%d asks.%d\n",exchange->name,base,rel,numbids,numasks); if ( numbids > 0 && (volume= bidasks[0].volume) > 0. && (profitmargin= tradebot_liquidity_active(myinfo,&price,exchange->name,base,rel,volume)) > 0. ) { diff --git a/iguana/kmd_lookup.h b/iguana/kmd_lookup.h index 9955ddf28..bce6c3976 100755 --- a/iguana/kmd_lookup.h +++ b/iguana/kmd_lookup.h @@ -124,6 +124,7 @@ int32_t kmd_transactionvin(struct iguana_info *coin,bits256 spendtxid,int32_t vi void kmd_transactionvout(struct iguana_info *coin,struct kmd_transactionhh *ptr,int32_t vout,uint64_t amount,uint8_t type_rmd160[21],bits256 spendtxid,int32_t spendvini) { struct kmd_addresshh *addr; struct kmd_transaction *tx = 0; + if ( 0 ) { char coinaddr[64],str[65]; bitcoin_address(coinaddr,type_rmd160[0],&type_rmd160[1],20); @@ -304,9 +305,9 @@ cJSON *kmd_transactionjson(int32_t height,struct kmd_transactionhh *ptr,char *ty return(obj); } -cJSON *kmd_unspentjson(struct iguana_info *coin,int32_t height,struct kmd_transaction *tx,int32_t vout) +cJSON *kmd_unspentjson(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,struct kmd_transaction *tx,int32_t vout,int32_t is_listunspent) { - cJSON *item = cJSON_CreateObject(); + char *script; cJSON *txout,*item = cJSON_CreateObject(); jaddstr(item,"type","received"); jaddnum(item,"height",tx->height); jaddnum(item,"timestamp",tx->timestamp); @@ -315,6 +316,16 @@ cJSON *kmd_unspentjson(struct iguana_info *coin,int32_t height,struct kmd_transa jaddnum(item,"amount",dstr(tx->vouts[vout].amount)); if ( strcmp(coin->symbol,"KMD") == 0 ) jaddnum(item,"interest",dstr(_iguana_interest((uint32_t)time(NULL),coin->longestchain,tx->timestamp,tx->vouts[vout].amount))); + if ( coin->FULLNODE < 0 && is_listunspent != 0 ) + { + //char str[65]; printf("get spendscriptstr for %s/v%d\n",bits256_str(str,tx->txid),vout); + if ( (txout= dpow_gettxout(myinfo,coin,tx->txid,vout)) != 0 ) + { + if ( (script= jstr(txout,"scriptPubKey")) != 0 ) + jaddstr(item,"scriptPubKey",script); + free_json(txout); + } + } return(item); } @@ -412,14 +423,14 @@ cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode,cJSO //if ( fulltx == 0 ) { if ( mode == 0 ) - jaddi(array,kmd_unspentjson(coin,coin->kmd_height,ptr->tx,i)); + jaddi(array,kmd_unspentjson(coin,coin->kmd_height,ptr->tx,i,1)); else if ( mode == 1 ) jaddi(array,kmd_spentjson(coin->kmd_height,ptr->tx,i,spent)); else if ( mode == 2 ) { if ( spent != 0 ) jaddi(array,kmd_spentjson(coin->kmd_height,ptr->tx,i,spent)); - else jaddi(array,kmd_unspentjson(coin,coin->kmd_height,ptr->tx,i)); + else jaddi(array,kmd_unspentjson(coin,coin->kmd_height,ptr->tx,i,0)); } } /*else if ( flag == 0 )