Browse Source

Test

etomic
jl777 7 years ago
parent
commit
70e327ac99
  1. 2
      iguana/exchanges/LP_include.h
  2. 19
      iguana/exchanges/LP_remember.c
  3. 11
      iguana/exchanges/LP_swap.c
  4. 2
      iguana/exchanges/LP_utxos.c

2
iguana/exchanges/LP_include.h

@ -269,7 +269,7 @@ struct basilisk_swap
struct basilisk_swapmessage *messages; int32_t nummessages,sentflag;
char Bdeposit[64],Bpayment[64];
uint64_t otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2];
uint8_t persistent_pubkey33[33],changermd160[20],pad[15],verifybuf[100000];
uint8_t persistent_pubkey33[33],persistent_other33[33],changermd160[20],pad[15],verifybuf[100000];
};

19
iguana/exchanges/LP_remember.c

@ -152,7 +152,10 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx
fprintf(fp,",\"otherfee\":\"%s\"",bits256_str(str,swap->otherfee.I.actualtxid));
if ( bits256_nonz(swap->myfee.I.actualtxid) != 0 )
fprintf(fp,",\"myfee\":\"%s\"",bits256_str(str,swap->myfee.I.actualtxid));
fprintf(fp,",\"dest33\":\"");
fprintf(fp,",\"other33\":\"");
for (i=0; i<33; i++)
fprintf(fp,"%02x",swap->persistent_other33[i]);
fprintf(fp,"\",\"dest33\":\"");
for (i=0; i<33; i++)
fprintf(fp,"%02x",swap->persistent_pubkey33[i]);
fprintf(fp,"\"}\n");
@ -463,7 +466,7 @@ struct LP_swap_remember
uint64_t Atxfee,Btxfee,srcamount,destamount; int64_t values[sizeof(txnames)/sizeof(*txnames)];
uint32_t requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate;
int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)];
uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],pubkey33[33],Predeemscript[1024],Dredeemscript[1024];
uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33];
char src[64],dest[64],destaddr[64],Adestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[64],bobcoin[64],*txbytes[sizeof(txnames)/sizeof(*txnames)];
};
@ -508,7 +511,7 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap)
int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t quoteid)
{
char fname[1024],*fstr,*secretstr,*srcstr,*deststr,*dest33,*txname; long fsize; cJSON *item,*txobj,*array; bits256 privkey; uint32_t r,q; int32_t i,j,n;
char fname[1024],*fstr,*secretstr,*srcstr,*deststr,*dest33,*txname; long fsize; cJSON *item,*txobj,*array; bits256 privkey; uint32_t r,q; int32_t i,j,n; uint8_t other33[33];
memset(rswap,0,sizeof(*rswap));
rswap->requestid = requestid;
rswap->quoteid = quoteid;
@ -537,6 +540,16 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t
// printf("%02x",pubkey33[i]);
//printf(" <- %s dest33\n",dest33);
}
if ( (dest33= jstr(item,"other33")) != 0 && strlen(dest33) == 66 )
{
decode_hex(other33,33,dest33);
for (i=0; i<33; i++)
if ( other33[i] != 0 )
break;
if ( i < 33 )
memcpy(rswap->other33,other33,33);
//printf(" <- %s dest33\n",dest33);
}
if ( (rswap->plocktime= juint(item,"plocktime")) == 0 )
rswap->plocktime = LP_extract(requestid,quoteid,fname,"plocktime");
if ( (rswap->dlocktime= juint(item,"dlocktime")) == 0 )

11
iguana/exchanges/LP_swap.c

@ -177,6 +177,8 @@ uint32_t basilisk_requestid(struct basilisk_request *rp)
int32_t LP_pubkeys_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
{
int32_t i,datalen = 0;
for (i=0; i<33; i++)
data[datalen++] = swap->persistent_pubkey33[i];
for (i=0; i<sizeof(swap->deck)/sizeof(swap->deck[0][0]); i++)
datalen += iguana_rwnum(1,&data[datalen],sizeof(swap->deck[i>>1][i&1]),&swap->deck[i>>1][i&1]);
return(datalen);
@ -184,9 +186,14 @@ int32_t LP_pubkeys_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
int32_t LP_pubkeys_verify(struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
{
int32_t i,len = 0;
if ( datalen == sizeof(swap->otherdeck) )
int32_t i,nonz=0,len = 0; uint8_t other33[33];
if ( datalen == sizeof(swap->otherdeck)+33 )
{
for (i=0; i<33; i++)
if ( (other33[i]= data[len++]) != 0 )
nonz++;
if ( nonz > 8 )
memcpy(swap->persistent_other33,other33,33);
for (i=0; i<sizeof(swap->otherdeck)/sizeof(swap->otherdeck[0][0]); i++)
len += iguana_rwnum(0,&data[len],sizeof(swap->otherdeck[i>>1][i&1]),&swap->otherdeck[i>>1][i&1]);
return(0);

2
iguana/exchanges/LP_utxos.c

@ -355,7 +355,7 @@ struct LP_utxoinfo *LP_utxoadd(int32_t iambob,char *symbol,bits256 txid,int32_t
val2 = value2;
}
dispflag = 0;
if ( dispflag != 0 )
//if ( dispflag != 0 )
printf("%.8f %.8f %s iambob.%d %s utxoadd.(%.8f %.8f) %s %s\n",dstr(val),dstr(val2),coinaddr,iambob,symbol,dstr(value),dstr(value2),bits256_str(str,txid),bits256_str(str2,txid2));
dispflag = 1;
if ( (utxo= LP_utxofinds(iambob,txid,vout,txid2,vout2)) != 0 )

Loading…
Cancel
Save