From 5feeb3d25ba97c11e7db2ee8f1704e9f20122db5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 20 Apr 2017 10:46:03 +0300 Subject: [PATCH] Test --- .gitignore | 4 ++++ basilisk/basilisk_swap.c | 17 ++++++++++++----- iguana/dpow/dpow_rpc.c | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 1303afe77..3c50d4146 100755 --- a/.gitignore +++ b/.gitignore @@ -376,3 +376,7 @@ iguana/DB/SWAPS/217534954-2300638414 iguana/DB/SWAPS/2780026367-3028893038 iguana/DB/SWAPS/467080987-1442519493 + +iguana/DB/SWAPS/1504818827-1454232932 + +iguana/DB/SWAPS/4093850898-2949785771 diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 359a49027..7c6698d9e 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -3229,11 +3229,12 @@ char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment", "bob cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid) { - FILE *fp; struct iguana_info *coin; int32_t sentflags[sizeof(txnames)/sizeof(*txnames)],i,j,len,needflag,secretstart,redeemlen,addflag,finishedflag = 0,iambob = -1; int64_t srcamount,destamount=0,value,values[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],pubkey33[33],redeemscript[512],userdata[512]; uint32_t plocktime,dlocktime,expiration=0,r,q,state,otherstate; char *secretstr,*srcstr,*deststr,str[65],src[64],dest[64],fname[512],*fstr,*dest33,*symbol,*Adest,*Bdest,*AAdest,*ABdest,destaddr[64],Adestaddr[64],alicecoin[64],bobcoin[64],*txbytes[sizeof(txnames)/sizeof(*txnames)]; long fsize; cJSON *txobj,*item,*sentobj,*array; bits256 checktxid,txid,pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,zero,privkey,rev,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)]; + FILE *fp; struct iguana_info *coin; int32_t sentflags[sizeof(txnames)/sizeof(*txnames)],i,j,len,needflag,secretstart,redeemlen,addflag,origfinishedflag = 0,finishedflag = 0,iambob = -1; int64_t srcamount,destamount=0,value,values[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],pubkey33[33],redeemscript[512],userdata[512]; uint32_t plocktime,dlocktime,expiration=0,r,q,state,otherstate; char *secretstr,*srcstr,*deststr,str[65],src[64],dest[64],fname[512],*fstr,*dest33,*symbol,*Adest,*Bdest,*AAdest,*ABdest,destaddr[64],Adestaddr[64],alicecoin[64],bobcoin[64],*txbytes[sizeof(txnames)/sizeof(*txnames)]; long fsize; cJSON *txobj,*item,*sentobj,*array; bits256 checktxid,txid,pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,zero,privkey,rev,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)]; sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname); if ( (fp= fopen(fname,"rb")) != 0 ) { - finishedflag = 1; + origfinishedflag = finishedflag = 1; + fclose(fp); } memset(values,0,sizeof(values)); memset(txids,0,sizeof(txids)); @@ -3663,11 +3664,13 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t } jadd(item,"sentflags",array); jaddstr(item,"result","success"); - jaddstr(item,"status","finished"); + if ( finishedflag != 0 ) + jaddstr(item,"status","finished"); + else jaddstr(item,"status","pending"); bits256_str(str,paymentspent), jaddbits256(item,"paymentspent",paymentspent); bits256_str(str,Apaymentspent), jaddbits256(item,"Apaymentspent",Apaymentspent); bits256_str(str,depositspent), jaddbits256(item,"depositspent",depositspent); - if ( finishedflag != 0 ) + if ( origfinishedflag == 0 && finishedflag != 0 ) { //printf("SWAP %u-%u finished!\n",requestid,quoteid); sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname); @@ -3685,7 +3688,7 @@ cJSON *basilisk_remember(struct supernet_info *myinfo,int64_t *KMDtotals,int64_t char *basilisk_swaplist(struct supernet_info *myinfo) { - char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16],Btotal,Ktotal; int32_t i; + char fname[512],*status; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16],Btotal,Ktotal; int32_t i; memset(KMDtotals,0,sizeof(KMDtotals)); memset(BTCtotals,0,sizeof(BTCtotals)); //,statebits; int32_t optionduration; struct basilisk_request R; bits256 privkey; @@ -3708,7 +3711,11 @@ char *basilisk_swaplist(struct supernet_info *myinfo) if ( flag == 0 ) { if ( (item= basilisk_remember(myinfo,KMDtotals,BTCtotals,requestid,quoteid)) != 0 ) + { jaddi(array,item); + if ( (status= jstr(item,"status")) != 0 && strcmp(status,"pending") == 0 ) + break; + } } } fclose(fp); diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 38e3e8f00..9268e6df7 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -569,7 +569,7 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c jaddistr(array,signedtx); paramstr = jprint(array,1); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"sendrawtransaction",paramstr); - printf(">>>>>>>>>>> %s dpow_sendrawtransaction.(%s) -> %s\n",coin->symbol,paramstr,retstr); + printf(">>>>>>>>>>> %s dpow_sendrawtransaction.(%s) -> (%s)\n",coin->symbol,paramstr,retstr); free(paramstr); return(retstr); }