From 166c94cc7693e99463edb47b823fe5e0c13d307c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 28 Apr 2017 17:45:20 +0300 Subject: [PATCH] Test --- .gitignore | 4 ++++ basilisk/basilisk_swap.c | 2 +- basilisk/smartaddress.c | 14 ++++++++++++-- iguana/iguana_wallet.c | 8 +++++--- iguana/tests/DEXratio | 2 ++ 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100755 iguana/tests/DEXratio diff --git a/.gitignore b/.gitignore index a0469beac..9814a7d00 100755 --- a/.gitignore +++ b/.gitignore @@ -403,3 +403,7 @@ iguana/DB/SWAPS/3213598586-2281632307 iguana/DB/SWAPS/2686675855-3655454671 iguana/DB/SWAPS/1878868608-154367763 + +iguana/DB/SWAPS/1306454711-1938980379 + +iguana/DB/SWAPS/912783809-2523701920 diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index d31394425..b36395556 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -2731,7 +2731,7 @@ cJSON *basilisk_swapjson(struct supernet_info *myinfo,struct basilisk_swap *swap struct basilisk_swap *basilisk_thread_start(struct supernet_info *myinfo,bits256 privkey,struct basilisk_request *rp,uint32_t statebits,int32_t optionduration,int32_t reinit) { - int32_t i,m,n,iter; uint8_t pubkey33[33],data[64]; bits256 pubkey25519; uint32_t channel,starttime; cJSON *retarray,*item,*msgobj; struct iguana_info *coin; double pending=0.; struct basilisk_swap *swap = 0; + int32_t i,m,n,iter; uint8_t pubkey33[33]; bits256 pubkey25519; uint32_t channel,starttime; cJSON *retarray,*item,*msgobj; struct iguana_info *coin; double pending=0.; struct basilisk_swap *swap = 0; // statebits 1 -> client, 0 -> LP if ( myinfo->numswaps > 0 ) { diff --git a/basilisk/smartaddress.c b/basilisk/smartaddress.c index ea1ab2e6f..76de3948d 100755 --- a/basilisk/smartaddress.c +++ b/basilisk/smartaddress.c @@ -62,9 +62,13 @@ cJSON *smartaddress_extrajson(struct smartaddress *ap) cJSON *smartaddress_json(struct smartaddress *ap) { - char coinaddr[64]; int32_t j,n; struct iguana_info *coin; cJSON *array,*item,*retjson; + char coinaddr[64],symbol[64]; uint8_t desttype,tmp,rmd160[20]; int32_t j,n; struct iguana_info *coin,*dest; cJSON *array,*item,*retjson; retjson = cJSON_CreateObject(); jaddstr(retjson,"type",ap->typestr); + strcpy(symbol,ap->typestr), touppercase(symbol); + if ( (dest= iguana_coinfind(symbol)) != 0 ) + desttype = dest->chain->pubtype; + else desttype = 60; if ( (n= ap->numsymbols) > 0 ) { array = cJSON_CreateArray(); @@ -76,6 +80,12 @@ cJSON *smartaddress_json(struct smartaddress *ap) item = cJSON_CreateObject(); jaddstr(item,"coin",coin->symbol); jaddstr(item,"address",coinaddr); + if ( dest != 0 ) + { + bitcoin_addr2rmd160(&tmp,rmd160,coinaddr); + bitcoin_address(coinaddr,desttype,rmd160,20); + jaddstr(item,"dest",coinaddr); + } jaddnum(item,"maxbid",ap->symbols[j].maxbid); jaddnum(item,"minask",ap->symbols[j].minask); jadd(item,"extra",smartaddress_extrajson(ap)); @@ -99,7 +109,7 @@ void smartaddress_symboladd(struct smartaddress *ap,char *symbol,double maxbid,d safecopy(sp->symbol,symbol,sizeof(sp->symbol)); sp->maxbid = maxbid; sp->minask = minask; - printf("symboladd (%s) <- (%s %f %f)\n",ap->typestr,symbol,maxbid,minask); + printf("symboladd.%d (%s) <- (%s %f %f)\n",ap->numsymbols,ap->typestr,symbol,maxbid,minask); } } diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index e077f2192..21aa5b703 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1373,12 +1373,14 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout) } if ( bits256_nonz(myinfo->persistent_priv) != 0 ) { - char *jumblrstr,jumblr_passphrase[1024]; + char *jumblrstr,jumblr_passphrase[1024],coinaddr[64],KMDaddr[64]; bits256 privkey; sprintf(jumblr_passphrase,"jumblr %s",password); if ( (jumblrstr= jumblr_setpassphrase(myinfo,0,0,0,jumblr_passphrase)) != 0 ) free(jumblrstr); - smartaddress_add(myinfo,myinfo->persistent_priv,"kmd","BTC",0.,0.); - smartaddress_add(myinfo,myinfo->persistent_priv,"btc","KMD",0.,0.); + privkey = jumblr_privkey(myinfo,coinaddr,0,KMDaddr,"kmd "); + smartaddress_add(myinfo,privkey,"kmd","BTC",0.,0.); + privkey = jumblr_privkey(myinfo,coinaddr,0,KMDaddr,"btc "); + smartaddress_add(myinfo,privkey,"btc","KMD",0.,0.); } //basilisk_unspents_update(myinfo,coin); return(retstr); diff --git a/iguana/tests/DEXratio b/iguana/tests/DEXratio new file mode 100755 index 000000000..09365cc85 --- /dev/null +++ b/iguana/tests/DEXratio @@ -0,0 +1,2 @@ +#!/bin/bash +curl --url "http://127.0.0.1:7778" --data "{\"ratio\":0.97,\"agent\":\"InstantDEX\",\"method\":\"DEXratio\"}"