From 3f9797395884713d248ffb03cfc6850c5dfb5885 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 9 Aug 2018 05:32:20 -1100 Subject: [PATCH 1/6] +0conf prints --- iguana/exchanges/LP_instantdex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index 63068518b..f6f6f4e55 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -639,9 +639,9 @@ int64_t LP_dynamictrust(int64_t credits,bits256 pubkey,int64_t kmdvalue) printf("unfinished alice %llu r%u-r%u src.%s %.8f dest.%s %.8f -> price %.8f value %.8f\n",(long long)sp->aliceid,sp->Q.R.requestid,sp->Q.R.quoteid,sp->Q.srccoin,dstr(sp->Q.satoshis),sp->Q.destcoin,dstr(sp->Q.destsatoshis),(double)sp->Q.destsatoshis/(sp->Q.satoshis+1),dstr(LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis))); } } - //printf("REJECT: %s instantdex_credits %.8f vs (%.8f + current %.8f)\n",coinaddr,dstr(credits),dstr(swaps_kmdvalue),dstr(kmdvalue)); + printf("REJECT: %s instantdex_credits %.8f vs (%.8f + current %.8f)\n",coinaddr,dstr(credits),dstr(swaps_kmdvalue),dstr(kmdvalue)); } - if ( 0 && credits != 0 ) + if ( 1 && credits != 0 ) printf("%s %s othercredits %.8f debits %.8f + %.8f -> %.8f\n",coin->symbol,coinaddr,dstr(credits),dstr(swaps_kmdvalue),dstr(kmdvalue),dstr(credits - (swaps_kmdvalue+kmdvalue))); return(credits - (swaps_kmdvalue+kmdvalue)); } @@ -679,9 +679,9 @@ int64_t LP_instantdex_proofcheck(char *symbol,char *coinaddr,cJSON *proof,int32_ credits = ap->instantdex_credits; ap->didinstantdex = 1; ap->instantdextime = (uint32_t)time(NULL); - if ( 0 && ap->instantdex_credits > 0 ) + if ( 1 && ap->instantdex_credits > 0 ) printf("validated instantdex %s.[%d] proof.(%s) credits %.8f\n",othersmartaddr,num,jprint(proof,0),dstr(ap->instantdex_credits)); - } //else printf("cant find ap.%p or already did %d %.8f\n",ap,ap!=0?ap->didinstantdex:-1,ap!=0?dstr(ap->instantdex_credits):-1); + } else printf("cant find ap.%p or already did %d %.8f\n",ap,ap!=0?ap->didinstantdex:-1,ap!=0?dstr(ap->instantdex_credits):-1); } return(credits); } From 0374237c99b2bc2782bbf2b1542c883014332b1e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 9 Aug 2018 21:26:20 -1100 Subject: [PATCH 2/6] Test gettxout --- iguana/exchanges/LP_rpc.c | 6 ++++++ iguana/exchanges/LP_utxo.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index e5a3d3e12..17b9cf355 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -257,7 +257,10 @@ cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout) if ( (tx= LP_transactionfind(coin,txid)) != 0 && vout < tx->numvouts ) { if ( tx->outpoints[vout].spendheight > 0 ) + { + fprintf(stderr,"LP_gettxout (%s) tx->outpoints[vout].spendheight > 0\n",coinaddr); return(0); + } //return(LP_gettxout_json(txid,vout,tx->height,tx->outpoints[vout].coinaddr,tx->outpoints[vout].value)); } if ( coin->electrum == 0 ) @@ -281,7 +284,10 @@ cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout) if ( (up= LP_address_utxofind(coin,coinaddr,txid,vout)) != 0 ) { if ( up->spendheight > 0 ) + { + fprintf(stderr,"LP_gettxout (%s) up->spendheight > 0\n",coinaddr); return(0); + } //return(LP_gettxout_json(txid,vout,up->U.height,coinaddr,up->U.value)); } memset(zero.bytes,0,sizeof(zero)); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index b81ec3449..24b97bf3d 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1226,7 +1226,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol } else free_json(txobj); if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid2,vout2)) == 0 ) { - printf("Could not find tx out: %s %d\n", txid_str, vout2); + printf("Could not find tx out2: %s %d\n", txid_str, vout2); return (0); } else free_json(txobj); From db66058ae50a75637a70f738bcaf3547f5dd909e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 9 Aug 2018 21:35:58 -1100 Subject: [PATCH 3/6] Move gettxout check --- iguana/exchanges/LP_rpc.c | 16 ++++++++-------- iguana/exchanges/LP_utxo.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 17b9cf355..46043a1ab 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -254,17 +254,17 @@ cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout) return(cJSON_Parse("{\"error\":\"no coin\"}")); if ( bits256_nonz(txid) == 0 ) return(cJSON_Parse("{\"error\":\"null txid\"}")); - if ( (tx= LP_transactionfind(coin,txid)) != 0 && vout < tx->numvouts ) + if ( coin->electrum == 0 ) { - if ( tx->outpoints[vout].spendheight > 0 ) + if ( (tx= LP_transactionfind(coin,txid)) != 0 && vout < tx->numvouts ) { - fprintf(stderr,"LP_gettxout (%s) tx->outpoints[vout].spendheight > 0\n",coinaddr); - return(0); + if ( tx->outpoints[vout].spendheight > 0 ) + { + fprintf(stderr,"LP_gettxout (%s) tx->outpoints[vout].spendheight > 0\n",coinaddr); + return(0); + } + //return(LP_gettxout_json(txid,vout,tx->height,tx->outpoints[vout].coinaddr,tx->outpoints[vout].value)); } - //return(LP_gettxout_json(txid,vout,tx->height,tx->outpoints[vout].coinaddr,tx->outpoints[vout].value)); - } - if ( coin->electrum == 0 ) - { sprintf(buf,"[\"%s\", %d, true]",bits256_str(str,txid),vout); return(bitcoin_json(coin,"gettxout",buf)); } diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 24b97bf3d..41d008ea1 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1075,7 +1075,7 @@ uint64_t LP_txinterestvalue(uint64_t *interestp,char *destaddr,struct iguana_inf { if ( (value= LP_value_extract(txobj,0,txid)) == 0 ) { - char str[65]; printf("%s LP_txvalue.%s strange utxo.(%s) vout.%d\n",coin->symbol,bits256_str(str,txid),jprint(txobj,0),vout); + // char str[65]; printf("%s LP_txvalue.%s strange utxo.(%s) vout.%d\n",coin->symbol,bits256_str(str,txid),jprint(txobj,0),vout); } else if ( strcmp(coin->symbol,"KMD") == 0 ) { From 9d9eaeb66c7c064c03cff0cdc4c158da7f4432c5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 9 Aug 2018 21:45:37 -1100 Subject: [PATCH 4/6] -print --- iguana/exchanges/LP_instantdex.c | 2 +- iguana/exchanges/LP_rpc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index f6f6f4e55..db381bbcf 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -641,7 +641,7 @@ int64_t LP_dynamictrust(int64_t credits,bits256 pubkey,int64_t kmdvalue) } printf("REJECT: %s instantdex_credits %.8f vs (%.8f + current %.8f)\n",coinaddr,dstr(credits),dstr(swaps_kmdvalue),dstr(kmdvalue)); } - if ( 1 && credits != 0 ) + if ( 0 && credits != 0 ) printf("%s %s othercredits %.8f debits %.8f + %.8f -> %.8f\n",coin->symbol,coinaddr,dstr(credits),dstr(swaps_kmdvalue),dstr(kmdvalue),dstr(credits - (swaps_kmdvalue+kmdvalue))); return(credits - (swaps_kmdvalue+kmdvalue)); } diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 46043a1ab..74a6f3266 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -260,7 +260,7 @@ cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout) { if ( tx->outpoints[vout].spendheight > 0 ) { - fprintf(stderr,"LP_gettxout (%s) tx->outpoints[vout].spendheight > 0\n",coinaddr); + //fprintf(stderr,"LP_gettxout (%s) tx->outpoints[vout].spendheight > 0\n",coinaddr); return(0); } //return(LP_gettxout_json(txid,vout,tx->height,tx->outpoints[vout].coinaddr,tx->outpoints[vout].value)); @@ -285,7 +285,7 @@ cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout) { if ( up->spendheight > 0 ) { - fprintf(stderr,"LP_gettxout (%s) up->spendheight > 0\n",coinaddr); + //fprintf(stderr,"LP_gettxout (%s) up->spendheight > 0\n",coinaddr); return(0); } //return(LP_gettxout_json(txid,vout,up->U.height,coinaddr,up->U.value)); From 33bf3690fb41d7d5741a168acd7f3bf577cddf1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 9 Aug 2018 22:04:58 -1100 Subject: [PATCH 5/6] test --- iguana/exchanges/LP_ordermatch.c | 2 +- iguana/exchanges/LP_rpc.c | 4 ++-- iguana/exchanges/LP_transaction.c | 2 +- iguana/exchanges/LP_utxo.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index fc48bbf3e..878dd3f5b 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -445,7 +445,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb { if ( (m= LP_address_utxo_ptrs(coin,iambob,utxos,max,ap,coinaddr)) > 1 ) { - if ( 0 ) + if ( 1 ) { int32_t i; for (i=0; isymbol,txid,0)) != 0 ) + if ( (txobj= LP_gettx("LP_txhasnotarization",coin->symbol,txid,1)) != 0 ) { if ( (vins= jarray(&numvins,txobj,"vin")) != 0 ) { @@ -1163,7 +1163,7 @@ int32_t LP_txhasnotarization(bits256 *notarizedhashp,struct iguana_info *coin,bi vin = jitem(vins,i); spenttxid = jbits256(vin,"txid"); spentvout = jint(vin,"vout"); - if ( (spentobj= LP_gettx("LP_txhasnotarization",coin->symbol,spenttxid,0)) != 0 ) + if ( (spentobj= LP_gettx("LP_txhasnotarization",coin->symbol,spenttxid,1)) != 0 ) { if ( (vouts= jarray(&numvouts,spentobj,"vout")) != 0 ) { diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 32d1cab01..a58b4ae4a 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -2319,7 +2319,7 @@ int32_t LP_swap_getcoinaddr(char *symbol,char *coinaddr,bits256 txid,int32_t vou { cJSON *retjson; coinaddr[0] = 0; - if ( (retjson= LP_gettx("LP_swap_getcoinaddr",symbol,txid,0)) != 0 ) + if ( (retjson= LP_gettx("LP_swap_getcoinaddr",symbol,txid,1)) != 0 ) { LP_txdestaddr(coinaddr,txid,vout,retjson); free_json(retjson); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 41d008ea1..92f91e686 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -906,7 +906,7 @@ cJSON *LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter,cJS struct LP_transaction *tx; int32_t i,height,numvouts,numvins,spentvout; cJSON *vins,*vouts,*vout,*vin; bits256 spenttxid; char str[65]; if ( coin->inactive != 0 ) return(0); - if ( txobj != 0 || (txobj= LP_gettx("LP_transactioninit",coin->symbol,txid,0)) != 0 ) + if ( txobj != 0 || (txobj= LP_gettx("LP_transactioninit",coin->symbol,txid,1)) != 0 ) { if ( coin->electrum == 0 ) height = LP_txheight(coin,txid); @@ -972,7 +972,7 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid) return(height); if ( coin->electrum == 0 ) { - if ( (txobj= LP_gettx("LP_txheight",coin->symbol,txid,0)) != 0 ) + if ( (txobj= LP_gettx("LP_txheight",coin->symbol,txid,1)) != 0 ) { //*timestampp = juint(txobj,"locktime"); //*blocktimep = juint(txobj,"blocktime"); From 591219b7aa10c3ad93ba6e02bf402810e878ba7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 9 Aug 2018 22:10:20 -1100 Subject: [PATCH 6/6] test --- iguana/exchanges/LP_ordermatch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 878dd3f5b..563277f4b 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1123,13 +1123,14 @@ printf("bob %s received REQUEST.(%s) mpnet.%d fill.%d gtc.%d\n",bits256_str(str, return(0); } } + LP_address_utxo_reset(&num,coin); i = 0; while ( i < priceiters && price >= myprice ) { for (j=0; jdestsatoshis)); - if ( (butxo= LP_address_myutxopair(&B,1,utxos,max,LP_coinfind(qp->srccoin),qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 ) + if ( (butxo= LP_address_myutxopair(&B,1,utxos,max,coin,qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 ) { strcpy(qp->gui,G.gui); strcpy(qp->coinaddr,coin->smartaddr); @@ -1181,7 +1182,7 @@ printf("bob %s received REQUEST.(%s) mpnet.%d fill.%d gtc.%d\n",bits256_str(str, else if ( qp->fill != 0 || i == priceiters ) { printf("i.%d cant find utxopair aliceid.%llu %s/%s %.8f -> relvol %.8f txfee %.8f\n",i,(long long)qp->aliceid,qp->srccoin,qp->destcoin,dstr(LP_basesatoshis(dstr(qp->destsatoshis),price,qp->txfee,qp->desttxfee)),dstr(qp->destsatoshis),dstr(qp->txfee)); - if ( qp->gtc != 0 && qp->fill != 0 && coin != 0 ) + if ( qp->gtc != 0 && qp->fill != 0 && coin != 0 && coin->electrum == 0 ) { LP_address_utxo_reset(&num,coin); satoshis = LP_basesatoshis(dstr(qp->destsatoshis),price,qp->txfee,qp->desttxfee) + 3*qp->txfee;