From d4372457120ef7e81816cd976dba8239a512d5d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 1 Nov 2017 20:26:13 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_ordermatch.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 6da5f6f86..67e5db04d 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -908,10 +908,18 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel destsatoshis = SATOSHIDEN * relvolume; if ( (autxo= LP_utxo_bestfit(rel,destsatoshis + 2*desttxfee)) == 0 ) return(clonestr("{\"error\":\"cant find alice utxo that is big enough\"}")); - if ( destsatoshis < autxo->S.satoshis ) - autxo->S.satoshis = destsatoshis - 2*desttxfee; - else if ( autxo->S.satoshis < destsatoshis ) - destsatoshis = autxo->S.satoshis - 2*desttxfee; + if ( destsatoshis - 2*desttxfee < autxo->S.satoshis ) + { + destsatoshis -= 2*desttxfee; + autxo->S.satoshis = destsatoshis; + printf("first path dest %.8f from %.8f\n",dstr(destsatoshis),dstr(autxo->S.satoshis)); + } + else if ( autxo->S.satoshis - 2*desttxfee < destsatoshis ) + { + autxo->S.satoshis -= 2*desttxfee; + destsatoshis = autxo->S.satoshis; + printf("second path dest %.8f from %.8f\n",dstr(destsatoshis),dstr(autxo->S.satoshis)); + } if ( destsatoshis < (autxo->payment.value / LP_MINCLIENTVOL) || autxo->payment.value < desttxfee*LP_MINSIZE_TXFEEMULT ) { printf("destsatoshis %.8f vs utxo %.8f this would have triggered an quote error -13\n",dstr(destsatoshis),dstr(autxo->payment.value));