From 318169a018de4179f22aa788ab9d59a449c4bb56 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 11:02:55 +0400 Subject: [PATCH 01/18] Test --- iguana/exchanges/LP_swap.c | 6 ++++-- iguana/exchanges/LP_transaction.c | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index d03cfa668..fc68657df 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -848,10 +848,11 @@ void LP_bobloop(void *_swap) } } } - basilisk_swap_finished(swap); - free(swap); } else printf("swap timed out\n"); G.LP_pendingswaps--; + basilisk_swap_finished(swap); + free(swap); + free(data); } void LP_aliceloop(void *_swap) @@ -925,6 +926,7 @@ void LP_aliceloop(void *_swap) }*/ if ( swap->N.pair >= 0 ) nn_close(swap->N.pair), swap->N.pair = -1; + LP_swap_endcritical = (uint32_t)time(NULL); LP_swapwait(swap,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr)*2,swap->I.aliceconfirms == 0 ? 3 : 30); } } diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index c2dff6e2e..739711424 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -733,11 +733,11 @@ char *iguana_validaterawtx(void *ctx,struct iguana_info *coin,struct iguana_msgt else complete = 1; jadd(retjson,"interpreter",log); jadd(retjson,"complete",complete!=0?jtrue():jfalse()); - free(serialized), free(serialized2); if ( signedtx != 0 ) free(signedtx); free(V); } + free(serialized), free(serialized2); } //char str[65]; printf("got txid.(%s)\n",bits256_str(str,txid)); } @@ -1325,6 +1325,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) if ( (ap= LP_address_utxo_reset(coin)) == 0 ) { printf("LP_withdraw error utxo reset %s\n",coin->symbol); + free(V); return(0); } privkeys = cJSON_CreateArray(); @@ -1363,6 +1364,8 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) free_json(privkeys), privkeys = 0; if ( rawtx != 0 ) free(rawtx), rawtx = 0; + if ( signedtx != 0 ) + free(signedtx), signedtx = 0; } free(V); if ( vins != 0 ) From 9cafacd5aa68e20d5debd7d693e309d1ac642096 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:15:33 +0400 Subject: [PATCH 02/18] Test --- iguana/exchanges/LP_remember.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index b054f9fdb..d7d900371 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1393,6 +1393,7 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) } free(liststr); } + if ( 0 ) if ( (liststr= LP_recent_swaps(limit)) != 0 ) { if ( (retjson= cJSON_Parse(liststr)) != 0 ) From 72ac400f635ac2767d3dea4c3734ff6cd1d81c49 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:19:27 +0400 Subject: [PATCH 03/18] Test --- iguana/exchanges/LP_remember.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index d7d900371..946784dee 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1368,6 +1368,7 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) limit = 10; memset(ridqids,0,sizeof(ridqids)); retarray = cJSON_CreateArray(); + if ( 0 ) if ( (liststr= basilisk_swaplist(0,0,0)) != 0 ) { //printf("swapentry.(%s)\n",liststr); @@ -1393,7 +1394,6 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) } free(liststr); } - if ( 0 ) if ( (liststr= LP_recent_swaps(limit)) != 0 ) { if ( (retjson= cJSON_Parse(liststr)) != 0 ) From 39fd183083d6b4b3ec396edf989d70da220d9ed1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:21:19 +0400 Subject: [PATCH 04/18] Test --- iguana/exchanges/LP_remember.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 946784dee..72d687ffb 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1394,6 +1394,7 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) } free(liststr); } + if ( 0 ) if ( (liststr= LP_recent_swaps(limit)) != 0 ) { if ( (retjson= cJSON_Parse(liststr)) != 0 ) From 0c64f76e6344bf22810c6bdb4a1b5937cf5d8f2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:23:47 +0400 Subject: [PATCH 05/18] Test --- iguana/exchanges/LP_remember.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 72d687ffb..9af71a4e8 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1240,7 +1240,7 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc { if ( count < sizeof(ridqids)/sizeof(*ridqids) ) ridqids[count++] = ridqid; - if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,0)) != 0 ) + if ( 0 && (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,0)) != 0 ) jaddi(array,item); } } @@ -1368,7 +1368,6 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) limit = 10; memset(ridqids,0,sizeof(ridqids)); retarray = cJSON_CreateArray(); - if ( 0 ) if ( (liststr= basilisk_swaplist(0,0,0)) != 0 ) { //printf("swapentry.(%s)\n",liststr); @@ -1394,7 +1393,6 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) } free(liststr); } - if ( 0 ) if ( (liststr= LP_recent_swaps(limit)) != 0 ) { if ( (retjson= cJSON_Parse(liststr)) != 0 ) From 9c8bc8170d1c7a805228d94a35aa9432f4420720 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:25:42 +0400 Subject: [PATCH 06/18] Test --- iguana/exchanges/LP_remember.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 9af71a4e8..ad8b0fd16 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -893,6 +893,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti //printf("legacy DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); return(cJSON_Parse("{\"error\":\"mismatched bob/alice vs src/dest coins??\"}")); } + return(0); alice = LP_coinfind(rswap.alicecoin); bob = LP_coinfind(rswap.bobcoin); rswap.Atxfee = LP_txfeecalc(alice,rswap.Atxfee,0); @@ -1240,7 +1241,7 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc { if ( count < sizeof(ridqids)/sizeof(*ridqids) ) ridqids[count++] = ridqid; - if ( 0 && (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,0)) != 0 ) + if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,0)) != 0 ) jaddi(array,item); } } From 6ac7390597b007bfc355f1f218815c82bd974255 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:27:18 +0400 Subject: [PATCH 07/18] Test --- iguana/exchanges/LP_remember.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index ad8b0fd16..db01ed541 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -884,6 +884,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( (rswap.iambob= LP_rswap_init(&rswap,requestid,quoteid,forceflag)) < 0 ) return(cJSON_Parse("{\"error\":\"couldnt initialize rswap, are all coins active?\"}")); decode_hex(deadtxid.bytes,32,"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"); +return(0); LP_swap_load(&rswap,forceflag); memset(zero.bytes,0,sizeof(zero)); otheraddr[0] = 0; @@ -893,7 +894,6 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti //printf("legacy DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); return(cJSON_Parse("{\"error\":\"mismatched bob/alice vs src/dest coins??\"}")); } - return(0); alice = LP_coinfind(rswap.alicecoin); bob = LP_coinfind(rswap.bobcoin); rswap.Atxfee = LP_txfeecalc(alice,rswap.Atxfee,0); From ca2a1c54c95668ce74ae45fc96bcfc58aa85d6a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:29:25 +0400 Subject: [PATCH 08/18] Test --- iguana/exchanges/LP_remember.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index db01ed541..bd7bd0de6 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -712,6 +712,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) } free(fstr); } + return(0); for (i=0; i Date: Mon, 4 Dec 2017 12:31:36 +0400 Subject: [PATCH 09/18] Test --- iguana/exchanges/LP_remember.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index bd7bd0de6..a1a5e2195 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -712,7 +712,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) } free(fstr); } - return(0); for (i=0; iiambob = jint(txobj,"iambob"); txid = jbits256(txobj,"txid"); if ( bits256_nonz(txid) == 0 ) + { + free(fstr); continue; + } rswap->txids[i] = txid; if ( jstr(txobj,"Apayment") != 0 ) safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr)); From 2c85e264f6a89a9847e3eb6457cf2518b731fa67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 12:35:07 +0400 Subject: [PATCH 10/18] Test --- iguana/exchanges/LP_remember.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index a1a5e2195..e3a1eed24 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -730,6 +730,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) if ( bits256_nonz(txid) == 0 ) { free(fstr); + free_json(txobj); continue; } rswap->txids[i] = txid; From dd872c5a53df758c49aefac62a4b5f347f756a8d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 13:18:10 +0400 Subject: [PATCH 11/18] Test --- iguana/exchanges/LP_rpc.c | 2 +- iguana/exchanges/LP_transaction.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index a9dcfe1e3..ea836ec67 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -372,7 +372,7 @@ int32_t LP_address_isvalid(char *symbol,char *address) isvalid = 1; //printf("%s ismine (%s)\n",address,jprint(retjson,0)); } - //printf("%s\n",jprint(retjson,0)); + printf("%s\n",jprint(retjson,0)); free_json(retjson); } return(isvalid); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 739711424..9de797287 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1194,7 +1194,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf { if ( LP_address_isvalid(coin->symbol,coinaddr) <= 0 ) { - printf("LP_createrawtransaction %s i.%d of %d is invalid\n",coinaddr,i,numvouts); + printf("%s LP_createrawtransaction %s i.%d of %d is invalid\n",coin->symbol,coinaddr,i,numvouts); return(0); } if ( (value= SATOSHIDEN * jdouble(item,coinaddr)) <= 0 ) From bede70ec6084d1c0f66373bd45594f6503f19e65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 13:41:54 +0400 Subject: [PATCH 12/18] Test --- iguana/exchanges/LP_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index ea836ec67..a9dcfe1e3 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -372,7 +372,7 @@ int32_t LP_address_isvalid(char *symbol,char *address) isvalid = 1; //printf("%s ismine (%s)\n",address,jprint(retjson,0)); } - printf("%s\n",jprint(retjson,0)); + //printf("%s\n",jprint(retjson,0)); free_json(retjson); } return(isvalid); From 0786cc20ed2ec982565b3d2cc41785c428b3f2e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 13:49:24 +0400 Subject: [PATCH 13/18] Test --- iguana/exchanges/LP_transaction.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 9de797287..9cba66db9 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1255,6 +1255,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf if ( (value= SATOSHIDEN * jdouble(item,coinaddr)) <= 0 ) { printf("cant get value i.%d of %d %s\n",i,numvouts,jprint(outputs,0)); + free_json(txobj); return(0); } bitcoin_addr2rmd160(coin->taddr,&addrtype,rmd160,coinaddr); @@ -1272,6 +1273,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf else { printf("cant get fieldname.%d of %d %s\n",i,numvouts,jprint(outputs,0)); + free_json(txobj); return(0); } } @@ -1336,7 +1338,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) completed = 0; memset(&msgtx,0,sizeof(msgtx)); memset(signedtxid.bytes,0,sizeof(signedtxid)); - if ( (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,V,numvins,rawtx,vins,privkeys,coin->zcash)) < 0 ) + if ( 0 && (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,V,numvins,rawtx,vins,privkeys,coin->zcash)) < 0 ) printf("couldnt sign withdraw %s\n",bits256_str(str,signedtxid)); else if ( completed == 0 ) { From b7e98852c78dfc6faf161ead1e8a70d513501b7d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 13:57:02 +0400 Subject: [PATCH 14/18] Test --- iguana/exchanges/LP_transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 9cba66db9..176546e9b 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -511,7 +511,7 @@ int32_t iguana_signrawtransaction(void *ctx,char *symbol,uint8_t wiftaddr,uint8_ //printf("back from bitcoin_hex2json (%s)\n",jprint(vins,0)); } else printf("no txobj from bitcoin_hex2json\n"); //printf("call hex2json.(%s) vins.(%s)\n",rawtx,jprint(vins,0)); - if ( (numinputs= cJSON_GetArraySize(vins)) > 0 ) + if ( 0 && (numinputs= cJSON_GetArraySize(vins)) > 0 ) { //printf("numinputs.%d (%s) msgtx.%d\n",numinputs,jprint(vins,0),msgtx->tx_in); memset(msgtx,0,sizeof(*msgtx)); @@ -1338,7 +1338,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) completed = 0; memset(&msgtx,0,sizeof(msgtx)); memset(signedtxid.bytes,0,sizeof(signedtxid)); - if ( 0 && (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,V,numvins,rawtx,vins,privkeys,coin->zcash)) < 0 ) + if ( (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,V,numvins,rawtx,vins,privkeys,coin->zcash)) < 0 ) printf("couldnt sign withdraw %s\n",bits256_str(str,signedtxid)); else if ( completed == 0 ) { From 6c2a3ad74522e1be0c5a325272988e66520e834e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 14:00:19 +0400 Subject: [PATCH 15/18] Test --- iguana/exchanges/LP_transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 176546e9b..bac2a8b61 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -511,11 +511,11 @@ int32_t iguana_signrawtransaction(void *ctx,char *symbol,uint8_t wiftaddr,uint8_ //printf("back from bitcoin_hex2json (%s)\n",jprint(vins,0)); } else printf("no txobj from bitcoin_hex2json\n"); //printf("call hex2json.(%s) vins.(%s)\n",rawtx,jprint(vins,0)); - if ( 0 && (numinputs= cJSON_GetArraySize(vins)) > 0 ) + if ( (numinputs= cJSON_GetArraySize(vins)) > 0 ) { //printf("numinputs.%d (%s) msgtx.%d\n",numinputs,jprint(vins,0),msgtx->tx_in); memset(msgtx,0,sizeof(*msgtx)); - if ( iguana_rwmsgtx(symbol,taddr,pubtype,p2shtype,isPoS,height,0,0,serialized,maxsize,msgtx,&txid,"",extraspace,extralen,vins,V->suppress_pubkeys,zcash) > 0 && numinputs == msgtx->tx_in ) + if ( iguana_rwmsgtx(symbol,taddr,pubtype,p2shtype,isPoS,height,0,0,serialized,maxsize,msgtx,&txid,"",extraspace,extralen,vins,V->suppress_pubkeys,zcash) > 0 && numinputs == msgtx->tx_in && 0 ) { memset(pubkeys,0,sizeof(pubkeys)); memset(privkeys,0,sizeof(privkeys)); From a428c69ec35b9bd8738eca6eea0a524b352036bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 14:02:52 +0400 Subject: [PATCH 16/18] Test --- iguana/exchanges/LP_transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index bac2a8b61..c563e1ee5 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -477,7 +477,7 @@ int32_t bitcoin_verifyvins(void *ctx,char *symbol,uint8_t taddr,uint8_t pubtype, } } iguana_msgtx_Vset(serialized,maxlen,msgtx,V); - cJSON *txobj = cJSON_CreateObject(); + cJSON *txobj = 0;//cJSON_CreateObject(); *signedtx = iguana_rawtxbytes(symbol,taddr,pubtype,p2shtype,isPoS,height,txobj,msgtx,suppress_pubkeys,zcash); //printf("SIGNEDTX.(%s)\n",jprint(txobj,1)); *signedtxidp = msgtx->txid; @@ -515,7 +515,7 @@ int32_t iguana_signrawtransaction(void *ctx,char *symbol,uint8_t wiftaddr,uint8_ { //printf("numinputs.%d (%s) msgtx.%d\n",numinputs,jprint(vins,0),msgtx->tx_in); memset(msgtx,0,sizeof(*msgtx)); - if ( iguana_rwmsgtx(symbol,taddr,pubtype,p2shtype,isPoS,height,0,0,serialized,maxsize,msgtx,&txid,"",extraspace,extralen,vins,V->suppress_pubkeys,zcash) > 0 && numinputs == msgtx->tx_in && 0 ) + if ( iguana_rwmsgtx(symbol,taddr,pubtype,p2shtype,isPoS,height,0,0,serialized,maxsize,msgtx,&txid,"",extraspace,extralen,vins,V->suppress_pubkeys,zcash) > 0 && numinputs == msgtx->tx_in ) { memset(pubkeys,0,sizeof(pubkeys)); memset(privkeys,0,sizeof(privkeys)); From ac6a388aba719e6f33f5e52e7a25f870a3788644 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 14:50:28 +0400 Subject: [PATCH 17/18] Test --- iguana/exchanges/LP_include.h | 6 +++--- iguana/exchanges/LP_swap.c | 19 +++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 218dc7867..b008acdc7 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -180,12 +180,12 @@ struct vin_info uint8_t rmd160[20],spendscript[10000],p2shscript[10000],userdata[10000]; }; -struct basilisk_swapmessage +/*struct basilisk_swapmessage { bits256 srchash,desthash; uint32_t crc32,msgbits,quoteid,datalen; uint8_t *data; -}; +};*/ struct basilisk_swap; @@ -383,7 +383,7 @@ struct basilisk_swap struct basilisk_swapinfo I; struct basilisk_rawtx bobdeposit,bobpayment,alicepayment,myfee,otherfee,aliceclaim,alicespend,bobreclaim,bobspend,bobrefund,alicereclaim; bits256 privkeys[INSTANTDEX_DECKSIZE]; - struct basilisk_swapmessage *messages; int32_t nummessages,sentflag; + //struct basilisk_swapmessage *messages; int32_t nummessages,sentflag; char Bdeposit[64],Bpayment[64]; uint64_t aliceid,otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2]; uint8_t persistent_pubkey33[33],persistent_other33[33],changermd160[20],pad[15],verifybuf[100000]; diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index fc68657df..a0ab038e7 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -126,8 +126,8 @@ void basilisk_rawtx_purge(struct basilisk_rawtx *rawtx) void basilisk_swap_finished(struct basilisk_swap *swap) { - int32_t i; - /*if ( swap->utxo != 0 && swap->sentflag == 0 ) + /*int32_t i; + if ( swap->utxo != 0 && swap->sentflag == 0 ) { LP_availableset(swap->utxo); swap->utxo = 0; @@ -159,11 +159,11 @@ void basilisk_swap_finished(struct basilisk_swap *swap) basilisk_rawtx_purge(&swap->bobspend); basilisk_rawtx_purge(&swap->bobrefund); basilisk_rawtx_purge(&swap->alicereclaim); - for (i=0; inummessages; i++) + /*for (i=0; inummessages; i++) if ( swap->messages[i].data != 0 ) free(swap->messages[i].data), swap->messages[i].data = 0; free(swap->messages), swap->messages = 0; - swap->nummessages = 0; + swap->nummessages = 0;*/ if ( swap->N.pair >= 0 ) nn_close(swap->N.pair), swap->N.pair = -1; } @@ -837,7 +837,7 @@ void LP_bobloop(void *_swap) printf("error sending bobpayment\n"); //if ( LP_waitfor(swap->N.pair,swap,10,LP_verify_alicespend) < 0 ) // printf("error waiting for alicespend\n"); - swap->sentflag = 1; + //swap->sentflag = 1; swap->bobreclaim.utxovout = 0; swap->bobreclaim.utxotxid = swap->bobpayment.I.signedtxid; basilisk_bobpayment_reclaim(swap,swap->I.callduration); @@ -873,7 +873,7 @@ void LP_aliceloop(void *_swap) printf("error LP_sendwait mostprivs\n"); else if ( basilisk_alicetxs(swap->N.pair,swap,data,maxlen) != 0 ) printf("basilisk_alicetxs error\n"); - else + else if ( 0 ) { LP_swapsfp_update(&swap->I.req); LP_swap_critical = (uint32_t)time(NULL); @@ -905,7 +905,7 @@ void LP_aliceloop(void *_swap) char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,swap->I.alicestr,bits256_str(str,swap->alicepayment.I.signedtxid)); sleep(10); } - swap->sentflag = 1; + //swap->sentflag = 1; LP_swap_critical = (uint32_t)time(NULL); if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_bobpayment) < 0 ) printf("error waiting for bobpayment\n"); @@ -934,11 +934,6 @@ void LP_aliceloop(void *_swap) } } free(data); - if ( swap->N.pair >= 0 ) - { - nn_close(swap->N.pair); - swap->N.pair = -1; - } basilisk_swap_finished(swap); printf("finish swap.%p\n",swap); free(swap); From 98081bbcf0f8ffe89ff56cc2194f1f326b97c676 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 4 Dec 2017 14:50:59 +0400 Subject: [PATCH 18/18] Test --- iguana/exchanges/LP_swap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index a0ab038e7..f61b60f12 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -873,7 +873,7 @@ void LP_aliceloop(void *_swap) printf("error LP_sendwait mostprivs\n"); else if ( basilisk_alicetxs(swap->N.pair,swap,data,maxlen) != 0 ) printf("basilisk_alicetxs error\n"); - else if ( 0 ) + else { LP_swapsfp_update(&swap->I.req); LP_swap_critical = (uint32_t)time(NULL);