|
|
@ -880,7 +880,7 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap) |
|
|
|
return(numspent); |
|
|
|
} |
|
|
|
|
|
|
|
cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag) |
|
|
|
cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly) |
|
|
|
{ |
|
|
|
static void *ctx; |
|
|
|
struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64]; cJSON *item,*txoutobj; bits256 rev,signedtxid,zero,deadtxid; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; |
|
|
@ -1190,10 +1190,15 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti |
|
|
|
for (i=0; i<sizeof(txnames)/sizeof(*txnames); i++) |
|
|
|
if ( rswap.txbytes[i] != 0 ) |
|
|
|
free(rswap.txbytes[i]), rswap.txbytes[i] = 0; |
|
|
|
if ( pendingonly != 0 && rswap.origfinishedflag != 0 ) |
|
|
|
{ |
|
|
|
free_json(item); |
|
|
|
item = 0; |
|
|
|
} |
|
|
|
return(item); |
|
|
|
} |
|
|
|
|
|
|
|
char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forceflag) |
|
|
|
char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forceflag,int32_t pendingonly) |
|
|
|
{ |
|
|
|
uint64_t ridqids[4096],ridqid; char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t r,q,quoteid,requestid; int64_t KMDtotals[LP_MAXPRICEINFOS],BTCtotals[LP_MAXPRICEINFOS],Btotal,Ktotal; int32_t i,j,count=0; |
|
|
|
portable_mutex_lock(&LP_swaplistmutex); |
|
|
@ -1206,7 +1211,7 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc |
|
|
|
if ( origrequestid != 0 && origquoteid != 0 ) |
|
|
|
{ |
|
|
|
//printf("orig req.%u q.%u\n",origrequestid,origquoteid);
|
|
|
|
if ( (item= basilisk_remember(KMDtotals,BTCtotals,origrequestid,origquoteid,forceflag)) != 0 ) |
|
|
|
if ( (item= basilisk_remember(KMDtotals,BTCtotals,origrequestid,origquoteid,forceflag,0)) != 0 ) |
|
|
|
jaddi(array,item); |
|
|
|
//printf("got.(%s)\n",jprint(item,0));
|
|
|
|
} |
|
|
@ -1220,6 +1225,8 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc |
|
|
|
while ( fread(&requestid,1,sizeof(requestid),fp) == sizeof(requestid) && fread("eid,1,sizeof(quoteid),fp) == sizeof(quoteid) ) |
|
|
|
{ |
|
|
|
flag = 0; |
|
|
|
if ( pendingonly == 0 ) |
|
|
|
{ |
|
|
|
for (i=0; i<G.LP_numskips; i++) |
|
|
|
{ |
|
|
|
r = (uint32_t)(G.LP_skipstatus[i] >> 32); |
|
|
@ -1235,6 +1242,7 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ( flag == 0 ) |
|
|
|
{ |
|
|
|
ridqid = ((uint64_t)requestid << 32) | quoteid; |
|
|
@ -1245,7 +1253,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 ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,0,pendingonly)) != 0 ) |
|
|
|
jaddi(array,item); |
|
|
|
} |
|
|
|
} |
|
|
@ -1283,7 +1291,7 @@ char *basilisk_swapentry(uint32_t requestid,uint32_t quoteid,int32_t forceflag) |
|
|
|
cJSON *item; int64_t KMDtotals[LP_MAXPRICEINFOS],BTCtotals[LP_MAXPRICEINFOS]; |
|
|
|
memset(KMDtotals,0,sizeof(KMDtotals)); |
|
|
|
memset(BTCtotals,0,sizeof(BTCtotals)); |
|
|
|
if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,forceflag)) != 0 ) |
|
|
|
if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,forceflag,0)) != 0 ) |
|
|
|
return(jprint(item,1)); |
|
|
|
else return(clonestr("{\"error\":\"cant find requestid-quoteid\"}")); |
|
|
|
} |
|
|
@ -1373,7 +1381,7 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) |
|
|
|
limit = 10; |
|
|
|
memset(ridqids,0,sizeof(ridqids)); |
|
|
|
retarray = cJSON_CreateArray(); |
|
|
|
if ( (liststr= basilisk_swaplist(0,0,0)) != 0 ) |
|
|
|
if ( (liststr= basilisk_swaplist(0,0,0,0)) != 0 ) |
|
|
|
{ |
|
|
|
//printf("swapentry.(%s)\n",liststr);
|
|
|
|
if ( (retjson= cJSON_Parse(liststr)) != 0 ) |
|
|
|