From 08c0aabbc4f6b4e0a668d7bb4e9b4462db1b6815 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Dec 2017 16:06:57 +0400 Subject: [PATCH] Finished for alicepayment not sent and bob refund --- iguana/exchanges/LP_portfolio.c | 8 ++++++-- iguana/exchanges/LP_prices.c | 6 ++++-- iguana/exchanges/LP_remember.c | 9 +++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index 63cd8d45d..f149a5e1c 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -24,6 +24,7 @@ struct LP_autoprice_ref { char refbase[65],refrel[65],base[65],rel[65]; double margin,factor,offset; + cJSON *fundvalue; } LP_autorefs[100]; int32_t LP_autoprices,num_LP_autorefs; @@ -472,7 +473,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) int32_t LP_autoprice(void *ctx,char *base,char *rel,cJSON *argjson) { //curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"MNZ\",\"rel\":\"KMD\",\"offset\":0.1,\"refbase\":\"KMD\",\refrel\":\"BTC\",\"factor\":15000,\"margin\":0.01}" - struct LP_priceinfo *basepp,*relpp; int32_t i,retval = -1; char *refbase="",*refrel=""; double minprice,margin,offset,factor,fixedprice; + struct LP_priceinfo *basepp,*relpp; int32_t i,isfundvalue,retval = -1; char *refbase="",*refrel=""; double minprice,margin,offset,factor,fixedprice; //printf("autoprice.(%s %s) %s\n",base,rel,jprint(argjson,0)); if ( (basepp= LP_priceinfofind(base)) != 0 && (relpp= LP_priceinfofind(rel)) != 0 ) { @@ -488,7 +489,10 @@ int32_t LP_autoprice(void *ctx,char *base,char *rel,cJSON *argjson) basepp->margins[relpp->ind] = margin; basepp->offsets[relpp->ind] = offset; basepp->factors[relpp->ind] = factor; - if ( fixedprice > SMALLVAL || ((refbase= jstr(argjson,"refbase")) != 0 && (refrel= jstr(argjson,"refrel")) != 0) ) + refbase = jstr(argjson,"refbase"); + refrel = jstr(argjson,"refrel"); + isfundvalue = jint(argjson,"fundvalue"); + if ( isfundvalue != 0 || fixedprice > SMALLVAL || (refbase != 0 && refrel != 0) ) { if ( fixedprice > SMALLVAL ) { diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 7744ed1a6..98d8ee157 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -1140,7 +1140,7 @@ double LP_CMCbtcprice(double *price_usdp,char *symbol) cJSON *LP_fundvalue(cJSON *argjson) { - cJSON *holdings,*item,*newitem,*array,*retjson; int32_t i,iter,n; double usdprice,divisor,btcprice,balance,btcsum,KMDholdings,numKMD; struct iguana_info *coin; char *symbol,*coinaddr; int64_t fundvalue,KMDvalue = 0; + cJSON *holdings,*item,*newitem,*array,*retjson; int32_t i,iter,n,missing=0; double usdprice,divisor,btcprice,balance,btcsum,KMDholdings,numKMD; struct iguana_info *coin; char *symbol,*coinaddr; int64_t fundvalue,KMDvalue = 0; fundvalue = 0; KMDholdings = btcsum = 0.; array = cJSON_CreateArray(); @@ -1180,11 +1180,13 @@ cJSON *LP_fundvalue(cJSON *argjson) } else jaddstr(newitem,"error","no price source"); jaddi(array,newitem); - } + } else missing++; } } } retjson = cJSON_CreateObject(); + jaddstr(retjson,"result","success"); + jaddnum(retjson,"missing",missing); jadd(retjson,"holdings",array); btcprice = LP_CMCbtcprice(&usdprice,"komodo"); divisor = jdouble(argjson,"divisor"); diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 18f3310e5..f8aac6b49 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -380,8 +380,13 @@ int32_t basilisk_swap_isfinished(int32_t iambob,bits256 *txids,int32_t *sentflag } else { - if ( bits256_nonz(txids[BASILISK_ALICEPAYMENT]) == 0 && sentflags[BASILISK_ALICEPAYMENT] == 0 ) - return(1); + if ( sentflags[BASILISK_ALICEPAYMENT] == 0 ) + { + if ( bits256_nonz(txids[BASILISK_ALICEPAYMENT]) == 0 ) + return(1); + else if ( sentflags[BASILISK_BOBPAYMENT] != 0 && sentflags[BASILISK_BOBREFUND] != 0 ) + return(1); + } else { if ( sentflags[BASILISK_ALICERECLAIM] != 0 || sentflags[BASILISK_ALICESPEND] != 0 )