Browse Source

test

etomic
jl777 8 years ago
parent
commit
cf1d133d6a
  1. 35
      iguana/exchanges/LP_remember.c
  2. 4
      iguana/exchanges/LP_transaction.c

35
iguana/exchanges/LP_remember.c

@ -365,6 +365,33 @@ int32_t basilisk_swap_isfinished(int32_t iambob,bits256 *txids,int32_t *sentflag
return(0);
}
uint32_t LP_extract(uint32_t requestid,uint32_t quoteid,char *rootfname,char *field)
{
char fname[1024],*filestr,*redeemstr; long fsize; int32_t len; uint32_t t=0; cJSON *json; uint8_t redeem[1024];
if ( strcmp(field,"dlocktime") == 0 )
sprintf(fname,"%s.bobdeposit",rootfname);
else if ( strcmp(field,"plocktime") == 0 )
sprintf(fname,"%s.bobpayment",rootfname);
if ( (filestr= OS_filestr(&fsize,fname)) != 0 )
{
if ( (json= cJSON_Parse(filestr)) != 0 )
{
if ( (redeemstr= jstr(json,"redeem")) != 0 && (len= (int32_t)strlen(redeemstr)) <= sizeof(redeem)*2 )
{
len >>= 1;
decode_hex(redeem,len,redeemstr);
t = redeem[5];
t = (t << 8) | redeem[4];
t = (t << 8) | redeem[3];
t = (t << 8) | redeem[2];
printf("extracted timestamp.%u\n",t);
}
}
free(filestr);
}
return(t);
}
cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid)
{
static void *ctx;
@ -410,8 +437,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
// printf("%02x",pubkey33[i]);
//printf(" <- %s dest33\n",dest33);
}
plocktime = juint(item,"plocktime");
dlocktime = juint(item,"dlocktime");
if ( (plocktime= juint(item,"plocktime")) == 0 )
plocktime = LP_extract(requestid,quoteid,fname,"plocktime");
if ( (dlocktime= juint(item,"dlocktime")) == 0 )
dlocktime = LP_extract(requestid,quoteid,fname,"dlocktime");
r = juint(item,"requestid");
q = juint(item,"quoteid");
pubA0 = jbits256(item,"pubA0");
@ -570,7 +599,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
Atxfee = LP_MIN_TXFEE;
if ( (Btxfee= LP_getestimatedrate(bobcoin) * LP_AVETXSIZE) < LP_MIN_TXFEE )
Btxfee = LP_MIN_TXFEE;
printf("%s %.8f txfee, %s %.8f txfee\n",alicecoin,dstr(Atxfee),bobcoin,dstr(Btxfee));
//printf("%s %.8f txfee, %s %.8f txfee\n",alicecoin,dstr(Atxfee),bobcoin,dstr(Btxfee));
//printf("privAm.(%s) %p/%p\n",bits256_str(str,privAm),Adest,AAdest);
//printf("privBn.(%s) %p/%p\n",bits256_str(str,privBn),Bdest,ABdest);
if ( finishedflag == 0 && bobcoin[0] != 0 && alicecoin[0] != 0 )

4
iguana/exchanges/LP_transaction.c

@ -1367,12 +1367,12 @@ int32_t LP_verify_bobdeposit(struct basilisk_swap *swap,uint8_t *data,int32_t da
swap->aliceclaim.utxotxid = swap->bobdeposit.I.signedtxid = LP_broadcast_tx(swap->bobdeposit.name,swap->bobcoin.symbol,swap->bobdeposit.txbytes,swap->bobdeposit.I.datalen);
if ( bits256_nonz(swap->bobdeposit.I.signedtxid) != 0 )
swap->depositunconf = 1;
basilisk_dontforget_update(swap,&swap->bobdeposit);
len = basilisk_swapuserdata(userdata,zero,1,swap->I.myprivs[0],swap->bobdeposit.redeemscript,swap->bobdeposit.I.redeemlen);
memcpy(swap->I.userdata_aliceclaim,userdata,len);
swap->I.userdata_aliceclaimlen = len;
bitcoin_address(swap->bobdeposit.p2shaddr,swap->bobcoin.taddr,swap->bobcoin.p2shtype,swap->bobdeposit.redeemscript,swap->bobdeposit.I.redeemlen);
strcpy(swap->bobdeposit.I.destaddr,swap->bobdeposit.p2shaddr);
basilisk_dontforget_update(swap,&swap->bobdeposit);
//LP_importaddress(swap->bobcoin.symbol,swap->bobdeposit.I.destaddr);
/*for (i=0; i<swap->bobdeposit.I.datalen; i++)
printf("%02x",swap->bobdeposit.txbytes[i]);
@ -1431,12 +1431,12 @@ int32_t LP_verify_bobpayment(struct basilisk_swap *swap,uint8_t *data,int32_t da
swap->alicespend.utxotxid = swap->bobpayment.I.signedtxid = LP_broadcast_tx(swap->bobpayment.name,swap->bobpayment.coin->symbol,swap->bobpayment.txbytes,swap->bobpayment.I.datalen);
if ( bits256_nonz(swap->bobpayment.I.signedtxid) != 0 )
swap->paymentunconf = 1;
basilisk_dontforget_update(swap,&swap->bobpayment);
for (i=0; i<32; i++)
revAm.bytes[i] = swap->I.privAm.bytes[31-i];
len = basilisk_swapuserdata(userdata,revAm,0,swap->I.myprivs[0],swap->bobpayment.redeemscript,swap->bobpayment.I.redeemlen);
bitcoin_address(swap->bobpayment.p2shaddr,swap->bobcoin.taddr,swap->bobcoin.p2shtype,swap->bobpayment.redeemscript,swap->bobpayment.I.redeemlen);
strcpy(swap->bobpayment.I.destaddr,swap->bobpayment.p2shaddr);
basilisk_dontforget_update(swap,&swap->bobpayment);
//LP_importaddress(swap->bobcoin.symbol,swap->bobpayment.I.destaddr);
/*for (i=0; i<swap->bobpayment.I.datalen; i++)
printf("%02x",swap->bobpayment.txbytes[i]);

Loading…
Cancel
Save