From b4879162337d8bc823a5b2354e78a08aff36db2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 24 Oct 2017 21:34:21 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_ordermatch.c | 2 +- iguana/exchanges/LP_stats.c | 10 +++++++--- iguana/exchanges/LP_transaction.c | 2 +- iguana/exchanges/LP_utxo.c | 17 +++++++++++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index c999fe346..71a5eeefc 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -272,7 +272,7 @@ struct LP_utxoinfo *LP_address_utxopair(int32_t iambob,struct LP_address_utxo ** struct LP_address *ap; uint64_t targetval,targetval2; int32_t m,mini; struct LP_address_utxo *up,*up2; struct LP_utxoinfo *utxo = 0; if ( coin != 0 && (ap= LP_addressfind(coin,coinaddr)) != 0 ) { - if ( (m= LP_address_utxo_ptrs(iambob,utxos,max,ap,coinaddr)) > 1 ) + if ( (m= LP_address_utxo_ptrs(coin,iambob,utxos,max,ap,coinaddr)) > 1 ) { targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee); if ( 0 ) diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index e4c072493..3e9510754 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -43,7 +43,7 @@ uint64_t Ridqids[128]; int32_t LP_statslog_parsequote(char *method,cJSON *lineobj) { - int32_t i,duplicate=0; struct LP_quoteinfo Q; uint64_t ridqid; + int32_t i,destvout,feevout,duplicate=0; bits256 desttxid,feetxid; struct LP_quoteinfo Q; uint64_t ridqid; memset(&Q,0,sizeof(Q)); if ( LP_quoteparse(&Q,lineobj) < 0 ) { @@ -52,7 +52,11 @@ int32_t LP_statslog_parsequote(char *method,cJSON *lineobj) } else { - ridqid = (((uint64_t)Q.desttxid.uints[0] << 48) | ((uint64_t)Q.destvout << 32) || ((uint64_t)Q.feetxid.uints[0] << 16) | (uint32_t)Q.feevout); + desttxid = jbits256(lineobj,"desttxid"); + destvout = jint(lineobj,"destvout"); + feetxid = jbits256(lineobj,"feetxid"); + feevout = jint(lineobj,"feevout"); + ridqid = (((uint64_t)desttxid.uints[0] << 48) | ((uint64_t)destvout << 32) || ((uint64_t)feetxid.uints[0] << 16) | (uint32_t)feevout); for (i=0; i %d %s/v%d\n",method,(long long)ridqid,(int32_t)(LP_numridqids % (sizeof(Ridqids)/sizeof(*Ridqids))),bits256_str(str,jbits256(lineobj,"desttxid")),jint(lineobj,"destvout")); + char str[65]; printf("%10s ridqid.%-16llx -> %d %s/v%d\n",method,(long long)ridqid,(int32_t)(LP_numridqids % (sizeof(Ridqids)/sizeof(*Ridqids))),bits256_str(str,desttxid),destvout); } } return(duplicate == 0); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index b72cb111a..b1ad63380 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -955,7 +955,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf return(0); } memset(utxos,0,sizeof(utxos)); - if ( (numutxos= LP_address_utxo_ptrs(0,utxos,max,ap,coin->smartaddr)) <= 0 ) + if ( (numutxos= LP_address_utxo_ptrs(coin,0,utxos,max,ap,coin->smartaddr)) <= 0 ) { printf("LP_createrawtransaction: address_utxo_ptrs %d, error\n",numutxos); return(0); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 3ed28c5b3..bada9ffe2 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -138,9 +138,9 @@ struct LP_utxoinfo *LP_allocated(bits256 txid,int32_t vout) return(0); } -int32_t LP_address_utxo_ptrs(int32_t iambob,struct LP_address_utxo **utxos,int32_t max,struct LP_address *ap,char *coinaddr) +int32_t LP_address_utxo_ptrs(struct iguana_info *coin,int32_t iambob,struct LP_address_utxo **utxos,int32_t max,struct LP_address *ap,char *coinaddr) { - struct LP_address_utxo *up,*tmp; int32_t n = 0; + struct LP_address_utxo *up,*tmp; struct LP_transaction *tx; cJSON *txout; int32_t n = 0; //printf("LP_address_utxo_ptrs for (%s).(%s)\n",ap->coinaddr,coinaddr); if ( strcmp(ap->coinaddr,coinaddr) != 0 ) printf("UNEXPECTED coinaddr mismatch (%s) != (%s)\n",ap->coinaddr,coinaddr); @@ -150,6 +150,19 @@ int32_t LP_address_utxo_ptrs(int32_t iambob,struct LP_address_utxo **utxos,int32 //char str[65]; printf("LP_address_utxo_ptrs %s n.%d %.8f %s v%d spendheight.%d allocated.%p\n",ap->coinaddr,n,dstr(up->U.value),bits256_str(str,up->U.txid),up->U.vout,up->spendheight,LP_allocated(up->U.txid,up->U.vout)); if ( up->spendheight <= 0 ) { + if ( coin->electrum == 0 ) + { + if ( (txout= LP_gettxout(coin->symbol,coinaddr,up->U.txid,up->U.vout)) != 0 ) + free_json(txout); + else + { + char str[65]; printf("%s %s payment %s/v%d is spent\n",coin->symbol,coinaddr,bits256_str(str,up->U.txid),up->U.vout); + up->spendheight = 1; + if ( (tx= LP_transactionfind(coin,up->U.txid)) != 0 && up->U.vout < tx->numvouts ) + tx->outpoints[up->U.vout].spendheight = 1; + continue; + } + } if ( LP_allocated(up->U.txid,up->U.vout) == 0 ) { utxos[n++] = up;