From 1cefa815042edf9abdad02f50d8cff537fa3709f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 12 Jul 2018 23:46:15 +0700 Subject: [PATCH 1/2] Use compareAddresses instead of string comparison on quoteparse. --- iguana/exchanges/LP_signatures.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 9acdbf330..00318551b 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -128,25 +128,29 @@ int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) safecopy(qp->gui,LP_gui,sizeof(qp->gui)); safecopy(qp->srccoin,jstr(argjson,"base"),sizeof(qp->srccoin)); safecopy(qp->uuidstr,jstr(argjson,"uuid"),sizeof(qp->uuidstr)); +#ifndef NOTETOMIC if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) { - if ( (etomicstr= jstr(argjson,"bobtomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) + if ( (etomicstr= jstr(argjson,"bobtomic")) == 0 || compareAddresses(etomicstr,etomic) == 0 ) { printf("etomic src mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); return(-1); } } +#endif safecopy(qp->coinaddr,jstr(argjson,"address"),sizeof(qp->coinaddr)); safecopy(qp->etomicsrc,jstr(argjson,"etomicsrc"),sizeof(qp->etomicsrc)); safecopy(qp->destcoin,jstr(argjson,"rel"),sizeof(qp->destcoin)); +#ifndef NOTETOMIC if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) { - if ( (etomicstr= jstr(argjson,"alicetomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) + if ( (etomicstr= jstr(argjson,"alicetomic")) == 0 || compareAddresses(etomicstr,etomic) == 0 ) { printf("etomic dest mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); return(-1); } } +#endif safecopy(qp->destaddr,jstr(argjson,"destaddr"),sizeof(qp->destaddr)); safecopy(qp->etomicdest,jstr(argjson,"etomicdest"),sizeof(qp->etomicdest)); qp->aliceid = j64bits(argjson,"aliceid"); From f56f2d6effd3227868054ce9b2b8424c12315912 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Jul 2018 16:15:37 +0700 Subject: [PATCH 2/2] Add additional logging to LP_iseligible. --- iguana/exchanges/LP_utxo.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 35482f3b5..b81ec3449 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1217,16 +1217,27 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol strcpy(destaddr,destaddr2); if ( coin != 0 ) { - if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid,vout)) == 0 ) - return(0); + char txid_str[100], txid2_str[100]; + bits256_str(txid_str, txid); + bits256_str(txid2_str, txid2); + if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid,vout)) == 0 ) { + printf("Could not find tx out: %s %d\n", txid_str, vout); + return (0); + } else free_json(txobj); - if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid2,vout2)) == 0 ) - return(0); + if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid2,vout2)) == 0 ) { + printf("Could not find tx out: %s %d\n", txid_str, vout2); + return (0); + } else free_json(txobj); - if ( LP_numconfirms(coin->symbol,destaddr,txid,vout,0) <= 0 ) - return(0); - if ( LP_numconfirms(coin->symbol,destaddr,txid2,vout2,0) <= 0 ) - return(0); + if ( LP_numconfirms(coin->symbol,destaddr,txid,vout,0) <= 0 ) { + printf("Txid numconfirms is less or equal to zero: %s %d\n", txid_str, vout); + return (0); + } + if ( LP_numconfirms(coin->symbol,destaddr,txid2,vout2,0) <= 0 ) { + printf("Txid numconfirms is less or equal to zero: %s %d\n", txid2_str, vout2); + return (0); + } } return(1); }