diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 95a3d616f..7ebda4f53 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -679,11 +679,16 @@ char *LP_connectedalice(cJSON *argjson) // alice clonestr("{\"error\":\"cant parse quote\"}"); if ( bits256_cmp(Q.desthash,G.LP_mypub25519) != 0 ) return(clonestr("{\"result\",\"update stats\"}")); - printf("CONNECTED.(%s)\n",jprint(argjson,0)); + printf("CONNECTED.(%s) numpending.%d\n",jprint(argjson,0),G.LP_pendingswaps); + if ( G.LP_pendingswaps > 0 ) + { + printf("swap already pending\n"); + return(clonestr("{\"error\":\"swap already pending\"}")); + } autxo = &A; butxo = &B; LP_abutxo_set(autxo,butxo,&Q); - if ( (autxo= LP_utxopairfind(0,Q.txid,Q.vout,Q.txid2,Q.vout2)) != 0 && autxo->S.swap != 0 ) + /*if ( (autxo= LP_utxopairfind(0,Q.txid,Q.vout,Q.txid2,Q.vout2)) != 0 && autxo->S.swap != 0 ) { printf("swap already pending\n"); return(clonestr("{\"error\":\"swap already pending\"}")); @@ -693,11 +698,11 @@ char *LP_connectedalice(cJSON *argjson) // alice { printf("couldnt create autxo\n"); return(clonestr("{\"error\":\"couldnt create autxo\"}")); - } + }*/ if ( (qprice= LP_quote_validate(autxo,butxo,&Q,0)) <= SMALLVAL ) { LP_availableset(autxo); - G.LP_pendingswaps--; + //G.LP_pendingswaps--; printf("quote validate error %.0f\n",qprice); return(clonestr("{\"error\":\"quote validation error\"}")); } @@ -705,7 +710,7 @@ char *LP_connectedalice(cJSON *argjson) // alice { printf("this node has no price for %s/%s (%.8f %.8f)\n",Q.destcoin,Q.srccoin,bid,ask); LP_availableset(autxo); - G.LP_pendingswaps--; + //G.LP_pendingswaps--; return(clonestr("{\"error\":\"no price set\"}")); } // SPV validate bobs @@ -713,7 +718,7 @@ char *LP_connectedalice(cJSON *argjson) // alice price = bid; if ( (coin= LP_coinfind(Q.destcoin)) == 0 ) { - G.LP_pendingswaps--; + //G.LP_pendingswaps--; return(clonestr("{\"error\":\"cant get alicecoin\"}")); } Q.privkey = LP_privkey(Q.destaddr,coin->taddr); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 32d255a5b..3821605c7 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -821,6 +821,7 @@ void LP_aliceloop(void *_swap) nn_close(swap->N.pair); swap->N.pair = -1; } + G.LP_pendingswaps--; } bits256 instantdex_derivekeypair(void *ctx,bits256 *newprivp,uint8_t pubkey[33],bits256 privkey,bits256 orderhash)