diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index cfc356d81..32d740ab7 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -435,25 +435,6 @@ int32_t LP_nanobind(void *ctx,char *pairstr) return(pairsock); } -/*struct LP_utxoinfo BUTXOS[100]; - -int32_t LP_butxo_findeither(bits256 txid,int32_t vout) -{ - struct LP_utxoinfo *utxo; int32_t i,retval = 0; - portable_mutex_lock(&LP_butxomutex); - for (i=0; ipayment.vout && bits256_cmp(txid,utxo->payment.txid)) == 0 || (vout == utxo->deposit.vout && bits256_cmp(txid,utxo->deposit.txid) == 0) ) - { - retval = 1; - break; - } - } - portable_mutex_unlock(&LP_butxomutex); - return(retval); -}*/ - int32_t LP_nearest_utxovalue(struct LP_address_utxo **utxos,int32_t n,uint64_t targetval) { int32_t i,mini = -1; int64_t dist; uint64_t mindist = (1LL << 60); @@ -489,7 +470,7 @@ struct LP_utxoinfo *LP_address_utxopair(int32_t iambob,struct LP_address_utxo ** if ( (m= LP_address_utxo_ptrs(iambob,utxos,max,ap)) > 1 ) { targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee); - if ( 1 ) + if ( 0 ) { int32_t i; for (i=0; ipayment.vout == utxo->payment.vout && butxo->deposit.vout == utxo->deposit.vout && bits256_nonz(butxo->payment.txid) != 0 && bits256_nonz(butxo->deposit.txid) != 0 && bits256_cmp(butxo->payment.txid,utxo->payment.txid) == 0 && bits256_cmp(butxo->deposit.txid,utxo->deposit.txid) == 0 ) - break; - if ( utxo->S.swap == 0 && now > utxo->T.swappending ) - memset(utxo,0,sizeof(*utxo)); - utxo = 0; - } - //portable_mutex_unlock(&LP_butxomutex); - return(utxo); -} - -struct LP_utxoinfo *LP_butxo_add(struct LP_utxoinfo *butxo) -{ - static struct LP_utxoinfo zeroes; - int32_t i; struct LP_utxoinfo *utxo=0; - portable_mutex_lock(&LP_butxomutex); - if ( (utxo= _LP_butxo_find(butxo)) == 0 ) - { - for (i=0; iS = srcutxo->S; - destutxo->T = srcutxo->T; -} - -void LP_butxo_swapfields(struct LP_utxoinfo *butxo) -{ - struct LP_utxoinfo *getutxo=0; - portable_mutex_lock(&LP_butxomutex); - if ( (getutxo= _LP_butxo_find(butxo)) != 0 ) - LP_butxo_swapfields_copy(butxo,getutxo); - portable_mutex_unlock(&LP_butxomutex); -} - -void LP_butxo_swapfields_set(struct LP_utxoinfo *butxo) -{ - struct LP_utxoinfo *setutxo; - if ( (setutxo= LP_butxo_add(butxo)) != 0 ) - { - LP_butxo_swapfields_copy(setutxo,butxo); - } -}*/ - void LP_abutxo_set(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,struct LP_quoteinfo *qp) { if ( butxo != 0 ) @@ -824,7 +742,6 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, memset(autxo,0,sizeof(*autxo)); memset(butxo,0,sizeof(*butxo)); LP_abutxo_set(autxo,butxo,&Q); - printf("A %p, B %p\n",autxo,butxo); //LP_butxo_swapfields(butxo); if ( strcmp(method,"request") == 0 ) { @@ -974,6 +891,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q } else { + printf("invalid price %.8f\n",price); jaddnum(bestitem,"maxprice",maxprice); jaddstr(bestitem,"status","no response to request"); } diff --git a/iguana/exchanges/LP_statemachine.c b/iguana/exchanges/LP_statemachine.c index 073832675..29af48553 100644 --- a/iguana/exchanges/LP_statemachine.c +++ b/iguana/exchanges/LP_statemachine.c @@ -1608,6 +1608,87 @@ int32_t LP_utxopurge(int32_t allutxos) portable_mutex_unlock(&LP_utxomutex); return(n); } +/*struct LP_utxoinfo *_LP_butxo_find(struct LP_utxoinfo *butxo) + { + int32_t i; struct LP_utxoinfo *utxo=0; uint32_t now = (uint32_t)time(NULL); + //portable_mutex_lock(&LP_butxomutex); + for (i=0; ipayment.vout == utxo->payment.vout && butxo->deposit.vout == utxo->deposit.vout && bits256_nonz(butxo->payment.txid) != 0 && bits256_nonz(butxo->deposit.txid) != 0 && bits256_cmp(butxo->payment.txid,utxo->payment.txid) == 0 && bits256_cmp(butxo->deposit.txid,utxo->deposit.txid) == 0 ) + break; + if ( utxo->S.swap == 0 && now > utxo->T.swappending ) + memset(utxo,0,sizeof(*utxo)); + utxo = 0; + } + //portable_mutex_unlock(&LP_butxomutex); + return(utxo); + } + + struct LP_utxoinfo *LP_butxo_add(struct LP_utxoinfo *butxo) + { + static struct LP_utxoinfo zeroes; + int32_t i; struct LP_utxoinfo *utxo=0; + portable_mutex_lock(&LP_butxomutex); + if ( (utxo= _LP_butxo_find(butxo)) == 0 ) + { + for (i=0; iS = srcutxo->S; + destutxo->T = srcutxo->T; + } + + void LP_butxo_swapfields(struct LP_utxoinfo *butxo) + { + struct LP_utxoinfo *getutxo=0; + portable_mutex_lock(&LP_butxomutex); + if ( (getutxo= _LP_butxo_find(butxo)) != 0 ) + LP_butxo_swapfields_copy(butxo,getutxo); + portable_mutex_unlock(&LP_butxomutex); + } + + void LP_butxo_swapfields_set(struct LP_utxoinfo *butxo) + { + struct LP_utxoinfo *setutxo; + if ( (setutxo= LP_butxo_add(butxo)) != 0 ) + { + LP_butxo_swapfields_copy(setutxo,butxo); + } + }*/ +/*struct LP_utxoinfo BUTXOS[100]; + + int32_t LP_butxo_findeither(bits256 txid,int32_t vout) + { + struct LP_utxoinfo *utxo; int32_t i,retval = 0; + portable_mutex_lock(&LP_butxomutex); + for (i=0; ipayment.vout && bits256_cmp(txid,utxo->payment.txid)) == 0 || (vout == utxo->deposit.vout && bits256_cmp(txid,utxo->deposit.txid) == 0) ) + { + retval = 1; + break; + } + } + portable_mutex_unlock(&LP_butxomutex); + return(retval); + }*/ + struct LP_utxoinfo *LP_utxoaddjson(int32_t iambob,int32_t pubsock,cJSON *argjson) { struct LP_utxoinfo *utxo; diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 49009c739..e98fd497a 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -506,7 +506,7 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri txfee = LP_txfeecalc(coin,0); if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) { - printf("%s %s\n",coin->symbol,jprint(array,0)); + //printf("%s %s\n",coin->symbol,jprint(array,0)); for (iambob=0; iambob<=1; iambob++) { if ( iambob == 0 )