jl777 8 years ago
parent
commit
5085bb9f33
  1. 2
      basilisk/basilisk.h
  2. 36
      basilisk/basilisk_swap.c

2
basilisk/basilisk.h

@ -16,7 +16,7 @@
#ifndef H_BASILISK_H #ifndef H_BASILISK_H
#define H_BASILISK_H #define H_BASILISK_H
//#define BASILISK_DISABLESENDTX #define BASILISK_DISABLESENDTX
#define BASILISK_DISABLEWAITTX #define BASILISK_DISABLEWAITTX
#include "../iguana/iguana777.h" #include "../iguana/iguana777.h"

36
basilisk/basilisk_swap.c

@ -105,12 +105,15 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem
redeemscript[n++] = SCRIPT_OP_ELSE; redeemscript[n++] = SCRIPT_OP_ELSE;
if ( secretstartp != 0 ) if ( secretstartp != 0 )
*secretstartp = n + 2; *secretstartp = n + 2;
//n = bitcoin_revealsecret160(redeemscript,n,secret160); if ( 0 )
redeemscript[n++] = 0xa8;//IGUANA_OP_SHA256; n = bitcoin_revealsecret160(redeemscript,n,secret160);
redeemscript[n++] = 0x20; else
memcpy(&script[n],secret256,0x20), n += 0x20; {
redeemscript[n++] = 0x88; //SCRIPT_OP_EQUALVERIFY; 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); n = bitcoin_pubkeyspend(redeemscript,n,pubkeyB);
redeemscript[n++] = SCRIPT_OP_ENDIF; redeemscript[n++] = SCRIPT_OP_ENDIF;
*redeemlenp = n; *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 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) ) if ( datalen == sizeof(bits256) )
{ {
for (j=0; j<32; j++) 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; swap->privBn = privkey;
vcalc_sha256(0,swap->secretBn256,privkey.bytes,sizeof(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)); char str[65]; printf("privi verified.(%s)\n",bits256_str(str,privkey));
return(0); 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) 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"); //printf("check otherchoosei\n");
if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 ) 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); 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)); 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); 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); 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 else
@ -1333,10 +1351,10 @@ void basilisk_swaploop(void *_swap)
printf("%02x",swap->pubB1.bytes[i]); printf("%02x",swap->pubB1.bytes[i]);
printf(" <- pubB1\n"); 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->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++) for (i=0; i<swap->bobpayment.redeemlen; i++)
printf("%02x",swap->bobpayment.redeemscript[i]); printf("%02x",swap->bobpayment.redeemscript[i]);
printf(" <- bobpayment.%d\n",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++) for (i=0; i<swap->bobdeposit.redeemlen; i++)
printf("%02x",swap->bobdeposit.redeemscript[i]); printf("%02x",swap->bobdeposit.redeemscript[i]);
printf(" <- bobdeposit.%d\n",i); printf(" <- bobdeposit.%d\n",i);

Loading…
Cancel
Save