Browse Source

test

etomic
jl777 8 years ago
parent
commit
ffe26dd334
  1. 2
      basilisk/basilisk.h
  2. 24
      basilisk/basilisk_swap.c
  3. 6
      basilisk/jumblr.c
  4. BIN
      iguana/DB/SWAPS/2809686646-301730922

2
basilisk/basilisk.h

@ -60,7 +60,7 @@ struct basilisk_rawtx
struct iguana_msgtx msgtx;
struct basilisk_rawtxinfo I;
struct iguana_info *coin;
char vinstr[8192];
char vinstr[8192],p2shaddr[64];
cJSON *vins;
uint8_t txbytes[16384],spendscript[512],redeemscript[1024],extraspace[4096];
};

24
basilisk/basilisk_swap.c

@ -673,6 +673,7 @@ int32_t basilisk_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,str
{
decode_hex(rawtx->spendscript,hexlen,hexstr);
rawtx->I.spendlen = hexlen;
bitcoin_address(rawtx->p2shaddr,rawtx->coin->chain->p2shtype,rawtx->spendscript,hexlen);
if ( swap != 0 )
basilisk_txlog(swap->myinfoptr,swap,rawtx,-1); // bobdeposit, bobpayment or alicepayment
retval = 0;
@ -875,6 +876,7 @@ int32_t basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swa
if ( depositflag == 0 )
{
swap->bobpayment.I.spendlen = basilisk_bobscript(swap->bobpayment.I.rmd160,swap->bobpayment.redeemscript,&swap->bobpayment.I.redeemlen,swap->bobpayment.spendscript,0,&swap->bobpayment.I.locktime,&swap->bobpayment.I.secretstart,&swap->I,0);
bitcoin_address(swap->bobpayment.p2shaddr,swap->bobcoin->chain->p2shtype,swap->bobpayment.I.rmd160,20);
//for (i=0; i<swap->bobpayment.redeemlen; i++)
// printf("%02x",swap->bobpayment.redeemscript[i]);
//printf(" <- bobpayment.%d\n",i);
@ -910,6 +912,7 @@ int32_t basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swa
else
{
swap->bobdeposit.I.spendlen = basilisk_bobscript(swap->bobdeposit.I.rmd160,swap->bobdeposit.redeemscript,&swap->bobdeposit.I.redeemlen,swap->bobdeposit.spendscript,0,&swap->bobdeposit.I.locktime,&swap->bobdeposit.I.secretstart,&swap->I,1);
bitcoin_address(swap->bobdeposit.p2shaddr,swap->bobcoin->chain->p2shtype,swap->bobdeposit.I.rmd160,20);
if ( genflag != 0 && (swap->bobdeposit.I.datalen == 0 || swap->bobrefund.I.datalen == 0) )
{
for (i=0; i<3; i++)
@ -1509,12 +1512,12 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,bits256 priv
}
if ( strcmp("BTC",swap->bobcoin->symbol) == 0 )
{
swap->I.bobconfirms = (1 + sqrt(dstr(swap->I.bobsatoshis) * .1));
swap->I.bobconfirms = (1*0 + sqrt(dstr(swap->I.bobsatoshis) * .1));
swap->I.aliceconfirms = MIN(BASILISK_DEFAULT_NUMCONFIRMS,swap->I.bobconfirms * 3);
}
else if ( strcmp("BTC",swap->alicecoin->symbol) == 0 )
{
swap->I.aliceconfirms = (1 + sqrt(dstr(swap->I.alicesatoshis) * .1));
swap->I.aliceconfirms = (1*0 + sqrt(dstr(swap->I.alicesatoshis) * .1));
swap->I.bobconfirms = MIN(BASILISK_DEFAULT_NUMCONFIRMS,swap->I.bobconfirms * 3);
}
else
@ -1552,13 +1555,13 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,bits256 priv
basilisk_rawtx_setparms("bobreclaim",swap->I.req.quoteid,&swap->bobreclaim,swap->bobcoin,swap->I.bobconfirms,3,swap->I.bobsatoshis,1,bobpub33,jumblrflag);
swap->bobreclaim.I.suppress_pubkeys = 1;
swap->bobreclaim.I.locktime = swap->I.started + swap->I.putduration + 1;
basilisk_rawtx_setparms("alicepayment",swap->I.req.quoteid,&swap->alicepayment,swap->alicecoin,swap->I.aliceconfirms,0,swap->I.alicesatoshis+swap->alicecoin->txfee,2,0,jumblrflag);
basilisk_rawtx_setparms("bobspend",swap->I.req.quoteid,&swap->bobspend,swap->alicecoin,swap->I.aliceconfirms,2,swap->I.alicesatoshis,1,bobpub33,jumblrflag);
swap->bobspend.I.suppress_pubkeys = 1;
basilisk_rawtx_setparms("alicereclaim",swap->I.req.quoteid,&swap->alicereclaim,swap->alicecoin,swap->I.aliceconfirms,2,swap->I.alicesatoshis,1,alicepub33,jumblrflag);
swap->alicereclaim.I.suppress_pubkeys = 1;
printf("IAMBOB.%d\n",swap->I.iambob);
return(swap);
}
// end of alice/bob code
@ -1732,7 +1735,7 @@ void basilisk_dontforget_userdata(char *userdataname,FILE *fp,uint8_t *script,in
void basilisk_dontforget(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,int32_t locktime,bits256 triggertxid)
{
char fname[512],str[65]; FILE *fp; int32_t i;
char fname[512],str[65],msigaddr[64]; FILE *fp; int32_t i,len; uint8_t redeemscript[256],script[256];
sprintf(fname,"%s/SWAPS/%u-%u.%s",GLOBAL_DBDIR,swap->I.req.requestid,swap->I.req.quoteid,rawtx->name), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
@ -1755,12 +1758,25 @@ void basilisk_dontforget(struct supernet_info *myinfo,struct basilisk_swap *swap
fprintf(fp,",\"amount\":%.8f",dstr(rawtx->I.amount));
if ( bits256_nonz(triggertxid) != 0 )
fprintf(fp,",\"trigger\":\"%s\"",bits256_str(str,triggertxid));
if ( swap->bobdeposit.p2shaddr[0] != 0 )
fprintf(fp,",\"Bdeposit\":\"%s\"",swap->bobdeposit.p2shaddr);
if ( swap->bobpayment.p2shaddr[0] != 0 )
fprintf(fp,",\"Bpayment\":\"%s\"",swap->bobpayment.p2shaddr);
if ( swap->alicepayment.p2shaddr[0] != 0 )
fprintf(fp,",\"Apayment\":\"%s\"",swap->alicepayment.p2shaddr);
if ( swap->bobdeposit.p2shaddr[0] != 0 )
fprintf(fp,",\"deposit\":\"%s\"",swap->bobdeposit.p2shaddr);
basilisk_dontforget_userdata("Aclaim",fp,swap->I.userdata_aliceclaim,swap->I.userdata_aliceclaimlen);
basilisk_dontforget_userdata("Areclaim",fp,swap->I.userdata_alicereclaim,swap->I.userdata_alicereclaimlen);
basilisk_dontforget_userdata("Aspend",fp,swap->I.userdata_alicespend,swap->I.userdata_alicespendlen);
basilisk_dontforget_userdata("Bspend",fp,swap->I.userdata_bobspend,swap->I.userdata_bobspendlen);
basilisk_dontforget_userdata("Breclaim",fp,swap->I.userdata_bobreclaim,swap->I.userdata_bobreclaimlen);
basilisk_dontforget_userdata("Brefund",fp,swap->I.userdata_bobrefund,swap->I.userdata_bobrefundlen);
if ( bits256_nonz(swap->I.pubAm) != 0 && bits256_nonz(swap->I.pubBn) != 0 )
{
basilisk_alicescript(redeemscript,&len,script,0,msigaddr,swap->alicecoin->chain->p2shtype,swap->I.pubAm,swap->I.pubBn);
fprintf(fp,"\",\"Adest\":\"%s\"",msigaddr);
}
fprintf(fp,"}\n");
fclose(fp);
}

6
basilisk/jumblr.c

@ -727,7 +727,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32
if ( coin->CMCname[0] != 0 )
jumblr_DEXupdate(myinfo,coin,coin->symbol,coin->CMCname,kmdcoin->DEXinfo.btcprice,kmdcoin->DEXinfo.avail);
}
if ( myinfo->IAMLP == 0 && kmdcoin->DEXinfo.btcprice > SMALLVAL )
if ( myinfo->numswaps == 0 && myinfo->IAMLP == 0 && kmdcoin->DEXinfo.btcprice > SMALLVAL )
{
double minbtc,btcavail; char *retstr; cJSON *vals; bits256 hash;
minbtc = (kmdcoin->DEXinfo.btcprice * 1.2) * (JUMBLR_INCR + 3*(JUMBLR_INCR * JUMBLR_FEE + JUMBLR_TXFEE));
@ -749,7 +749,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32
jaddstr(vals,"source","BTC");
jaddstr(vals,"dest","KMD");
jaddnum(vals,"amount",vol);
jaddnum(vals,"minprice",1./(1.015 * kmdcoin->DEXinfo.btcprice));
jaddnum(vals,"minprice",1./(1.02 * kmdcoin->DEXinfo.btcprice));
jaddnum(vals,"usejumblr",1);
jaddnum(vals,"DEXselector",1);
memset(hash.bytes,0,sizeof(hash));
@ -781,7 +781,7 @@ void jumblr_DEXcheck(struct supernet_info *myinfo,struct iguana_info *coin,int32
jaddstr(vals,"dest","BTC");
jaddnum(vals,"amount",vol);
//jaddnum(vals,"destamount",JUMBLR_INCR*kmdcoin->DEXinfo.btcprice);
jaddnum(vals,"minprice",kmdcoin->DEXinfo.btcprice/1.015);
jaddnum(vals,"minprice",kmdcoin->DEXinfo.btcprice/1.02);
jaddnum(vals,"usejumblr",1);
memset(hash.bytes,0,sizeof(hash));
kmdcoin->DEXinfo.KMDpending += vol;

BIN
iguana/DB/SWAPS/2809686646-301730922

Binary file not shown.
Loading…
Cancel
Save