|
|
@ -105,12 +105,15 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem |
|
|
|
redeemscript[n++] = SCRIPT_OP_ELSE; |
|
|
|
if ( secretstartp != 0 ) |
|
|
|
*secretstartp = n + 2; |
|
|
|
//n = bitcoin_revealsecret160(redeemscript,n,secret160);
|
|
|
|
redeemscript[n++] = 0xa8;//IGUANA_OP_SHA256;
|
|
|
|
redeemscript[n++] = 0x20; |
|
|
|
memcpy(&script[n],secret256,0x20), n += 0x20; |
|
|
|
redeemscript[n++] = 0x88; //SCRIPT_OP_EQUALVERIFY;
|
|
|
|
|
|
|
|
if ( 0 ) |
|
|
|
n = bitcoin_revealsecret160(redeemscript,n,secret160); |
|
|
|
else |
|
|
|
{ |
|
|
|
redeemscript[n++] = 0xa8;//IGUANA_OP_SHA256;
|
|
|
|
redeemscript[n++] = 0x20; |
|
|
|
memcpy(&script[n],secret256,0x20), n += 0x20; |
|
|
|
redeemscript[n++] = 0x88; //SCRIPT_OP_EQUALVERIFY;
|
|
|
|
} |
|
|
|
n = bitcoin_pubkeyspend(redeemscript,n,pubkeyB); |
|
|
|
redeemscript[n++] = SCRIPT_OP_ENDIF; |
|
|
|
*redeemlenp = n; |
|
|
@ -471,7 +474,7 @@ int32_t basilisk_verify_pubpair(int32_t *wrongfirstbytep,struct basilisk_swap *s |
|
|
|
|
|
|
|
int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen) |
|
|
|
{ |
|
|
|
int32_t j,wrongfirstbyte,len = 0; bits256 privkey,pubi; uint8_t secret160[20],pubkey33[33]; uint64_t txid; struct basilisk_swap *swap = ptr; |
|
|
|
int32_t i,j,wrongfirstbyte,len = 0; bits256 privkey,pubi; char str[65],str2[65]; uint8_t secret160[20],pubkey33[33]; uint64_t txid; struct basilisk_swap *swap = ptr; |
|
|
|
if ( datalen == sizeof(bits256) ) |
|
|
|
{ |
|
|
|
for (j=0; j<32; j++) |
|
|
@ -490,6 +493,15 @@ int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *da |
|
|
|
{ |
|
|
|
swap->privBn = privkey; |
|
|
|
vcalc_sha256(0,swap->secretBn256,privkey.bytes,sizeof(privkey)); |
|
|
|
printf("set privBn.%s %s\n",bits256_str(str,swap->privBn),bits256_str(str2,*(bits256 *)swap->secretBn256)); |
|
|
|
swap->bobpayment.spendlen = basilisk_bobscript(swap->bobpayment.rmd160,swap->bobpayment.redeemscript,&swap->bobpayment.redeemlen,swap->bobpayment.spendscript,0,&swap->bobpayment.locktime,&swap->bobpayment.secretstart,swap,0); |
|
|
|
for (i=0; i<swap->bobpayment.redeemlen; i++) |
|
|
|
printf("%02x",swap->bobpayment.redeemscript[i]); |
|
|
|
printf(" <- bobpayment.%d\n",i); |
|
|
|
swap->bobdeposit.spendlen = basilisk_bobscript(swap->bobdeposit.rmd160,swap->bobdeposit.redeemscript,&swap->bobdeposit.redeemlen,swap->bobdeposit.spendscript,0,&swap->bobdeposit.locktime,&swap->bobdeposit.secretstart,swap,1); |
|
|
|
for (i=0; i<swap->bobdeposit.redeemlen; i++) |
|
|
|
printf("%02x",swap->bobdeposit.redeemscript[i]); |
|
|
|
printf(" <- bobdeposit.%d\n",i); |
|
|
|
} |
|
|
|
char str[65]; printf("privi verified.(%s)\n",bits256_str(str,privkey)); |
|
|
|
return(0); |
|
|
@ -1187,7 +1199,7 @@ void basilisk_sendchoosei(struct supernet_info *myinfo,struct basilisk_swap *swa |
|
|
|
|
|
|
|
void basilisk_waitchoosei(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) |
|
|
|
{ |
|
|
|
uint8_t pubkey33[33]; char str[65],str2[65]; |
|
|
|
uint8_t pubkey33[33]; char str[65],str2[65]; int32_t i; |
|
|
|
//printf("check otherchoosei\n");
|
|
|
|
if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 ) |
|
|
|
{ |
|
|
@ -1202,7 +1214,13 @@ void basilisk_waitchoosei(struct supernet_info *myinfo,struct basilisk_swap *swa |
|
|
|
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey33,swap->privBn); |
|
|
|
printf("set privBn.%s %s\n",bits256_str(str,swap->privBn),bits256_str(str2,*(bits256 *)swap->secretBn256)); |
|
|
|
swap->bobpayment.spendlen = basilisk_bobscript(swap->bobpayment.rmd160,swap->bobpayment.redeemscript,&swap->bobpayment.redeemlen,swap->bobpayment.spendscript,0,&swap->bobpayment.locktime,&swap->bobpayment.secretstart,swap,0); |
|
|
|
for (i=0; i<swap->bobpayment.redeemlen; i++) |
|
|
|
printf("%02x",swap->bobpayment.redeemscript[i]); |
|
|
|
printf(" <- bobpayment.%d\n",i); |
|
|
|
swap->bobdeposit.spendlen = basilisk_bobscript(swap->bobdeposit.rmd160,swap->bobdeposit.redeemscript,&swap->bobdeposit.redeemlen,swap->bobdeposit.spendscript,0,&swap->bobdeposit.locktime,&swap->bobdeposit.secretstart,swap,1); |
|
|
|
for (i=0; i<swap->bobdeposit.redeemlen; i++) |
|
|
|
printf("%02x",swap->bobdeposit.redeemscript[i]); |
|
|
|
printf(" <- bobdeposit.%d\n",i); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
@ -1333,10 +1351,10 @@ void basilisk_swaploop(void *_swap) |
|
|
|
printf("%02x",swap->pubB1.bytes[i]); |
|
|
|
printf(" <- pubB1\n"); |
|
|
|
swap->bobpayment.spendlen = basilisk_bobscript(swap->bobpayment.rmd160,swap->bobpayment.redeemscript,&swap->bobpayment.redeemlen,swap->bobpayment.spendscript,0,&swap->bobpayment.locktime,&swap->bobpayment.secretstart,swap,0); |
|
|
|
swap->bobdeposit.spendlen = basilisk_bobscript(swap->bobdeposit.rmd160,swap->bobdeposit.redeemscript,&swap->bobdeposit.redeemlen,swap->bobdeposit.spendscript,0,&swap->bobdeposit.locktime,&swap->bobdeposit.secretstart,swap,1); |
|
|
|
for (i=0; i<swap->bobpayment.redeemlen; i++) |
|
|
|
printf("%02x",swap->bobpayment.redeemscript[i]); |
|
|
|
printf(" <- bobpayment.%d\n",i); |
|
|
|
swap->bobdeposit.spendlen = basilisk_bobscript(swap->bobdeposit.rmd160,swap->bobdeposit.redeemscript,&swap->bobdeposit.redeemlen,swap->bobdeposit.spendscript,0,&swap->bobdeposit.locktime,&swap->bobdeposit.secretstart,swap,1); |
|
|
|
for (i=0; i<swap->bobdeposit.redeemlen; i++) |
|
|
|
printf("%02x",swap->bobdeposit.redeemscript[i]); |
|
|
|
printf(" <- bobdeposit.%d\n",i); |
|
|
|