|
|
@ -847,11 +847,12 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap) |
|
|
|
cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid) |
|
|
|
{ |
|
|
|
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; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; |
|
|
|
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]; |
|
|
|
if ( ctx == 0 ) |
|
|
|
ctx = bitcoin_ctx(); |
|
|
|
if ( (rswap.iambob= LP_rswap_init(&rswap,requestid,quoteid)) < 0 ) |
|
|
|
return(cJSON_Parse("{\"error\":\"couldnt initialize rswap, are all coins active?\"}")); |
|
|
|
decode_hex(deadtxid.bytes,32,"dead0000000000000000000000000000"); |
|
|
|
LP_swap_load(&rswap); |
|
|
|
memset(zero.bytes,0,sizeof(zero)); |
|
|
|
otheraddr[0] = 0; |
|
|
@ -929,7 +930,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti |
|
|
|
{ |
|
|
|
if ( (txoutobj= LP_gettxout(rswap.bobcoin,rswap.bobpaymentaddr,rswap.txids[BASILISK_BOBPAYMENT],0)) != 0 ) |
|
|
|
free_json(txoutobj), flag = 0; |
|
|
|
else flag = -1; |
|
|
|
else flag = -1, rswap.paymentspent = deadtxid; |
|
|
|
if ( flag == 0 ) |
|
|
|
{ |
|
|
|
if ( bits256_nonz(rswap.txids[BASILISK_BOBPAYMENT]) != 0 ) |
|
|
@ -965,7 +966,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti |
|
|
|
{ |
|
|
|
if ( (txoutobj= LP_gettxout(rswap.bobcoin,rswap.bobdepositaddr,rswap.txids[BASILISK_BOBDEPOSIT],0)) != 0 ) |
|
|
|
free_json(txoutobj), flag = 0; |
|
|
|
else flag = -1; |
|
|
|
else flag = -1, rswap.depositspent = deadtxid; |
|
|
|
if ( flag == 0 ) |
|
|
|
{ |
|
|
|
if ( rswap.Dredeemlen != 0 ) |
|
|
@ -990,7 +991,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti |
|
|
|
{ |
|
|
|
if ( (txoutobj= LP_gettxout(rswap.alicecoin,rswap.alicepaymentaddr,rswap.txids[BASILISK_ALICEPAYMENT],0)) != 0 ) |
|
|
|
free_json(txoutobj), flag = 0; |
|
|
|
else flag = -1; |
|
|
|
else flag = -1, rswap.Apaymentspent = deadtxid; |
|
|
|
if ( flag == 0 ) |
|
|
|
{ |
|
|
|
rswap.privBn = basilisk_swap_privBn_extract(&rswap.txids[BASILISK_BOBREFUND],rswap.bobcoin,rswap.txids[BASILISK_BOBDEPOSIT],rswap.privBn); |
|
|
@ -1012,7 +1013,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti |
|
|
|
{ |
|
|
|
if ( (txoutobj= LP_gettxout(rswap.alicecoin,rswap.alicepaymentaddr,rswap.txids[BASILISK_ALICEPAYMENT],0)) != 0 ) |
|
|
|
free_json(txoutobj), flag = 0; |
|
|
|
else flag = -1; |
|
|
|
else flag = -1, rswap.Apaymentspent = deadtxid; |
|
|
|
if ( flag == 0 ) |
|
|
|
{ |
|
|
|
if ( bits256_nonz(rswap.privAm) == 0 ) |
|
|
@ -1033,7 +1034,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti |
|
|
|
{ |
|
|
|
if ( (txoutobj= LP_gettxout(rswap.bobcoin,rswap.bobpaymentaddr,rswap.txids[BASILISK_BOBPAYMENT],0)) != 0 ) |
|
|
|
free_json(txoutobj), flag = 0; |
|
|
|
else flag = -1; |
|
|
|
else flag = -1, rswap.paymentspent = deadtxid; |
|
|
|
if ( flag == 0 ) |
|
|
|
{ |
|
|
|
// bobreclaim
|
|
|
@ -1056,7 +1057,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti |
|
|
|
{ |
|
|
|
if ( (txoutobj= LP_gettxout(rswap.bobcoin,rswap.bobdepositaddr,rswap.txids[BASILISK_BOBDEPOSIT],0)) != 0 ) |
|
|
|
free_json(txoutobj), flag = 0; |
|
|
|
else flag = -1; |
|
|
|
else flag = -1, rswap.depositspent = deadtxid; |
|
|
|
if ( flag == 0 && (bits256_nonz(rswap.Apaymentspent) != 0 || time(NULL) > rswap.expiration) ) |
|
|
|
{ |
|
|
|
printf("do the refund! paymentspent.%s now.%u vs expiration.%u\n",bits256_str(str,rswap.paymentspent),(uint32_t)time(NULL),rswap.expiration); |
|
|
|