|
|
@ -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); |
|
|
|
} |
|
|
|