jl777 8 years ago
parent
commit
390c15b300
  1. 2
      basilisk/basilisk_swap.c
  2. 15
      iguana/iguana_interpreter.c
  3. 21
      iguana/iguana_sign.c

2
basilisk/basilisk_swap.c

@ -1368,7 +1368,7 @@ uint32_t basilisk_swapdata_rawtxsend(struct supernet_info *myinfo,struct basilis
memcpy(&sendbuf[sendlen],rawtx->redeemscript,rawtx->redeemlen);
sendlen += rawtx->redeemlen;
}
printf("sendlen.%d datalen.%d redeemlen.%d\n",sendlen,rawtx->datalen,rawtx->redeemlen);
//printf("sendlen.%d datalen.%d redeemlen.%d\n",sendlen,rawtx->datalen,rawtx->redeemlen);
return(basilisk_swapsend(myinfo,swap,msgbits,sendbuf,sendlen,nextbits,rawtx->crcs));
}
}

15
iguana/iguana_interpreter.c

@ -501,12 +501,12 @@ static int32_t iguana_pushdata(struct iguana_interpreter *stacks,int64_t num64,u
//printf("PUSH.(%lld %p %d)\n",(long long)num64,numbuf,numlen);
if ( stacks->maxstackdepth > 0 )
{
/*if ( numbuf != 0 )
if ( numbuf != 0 )
{
int32_t i; for (i=0; i<numlen; i++)
printf("%02x",numbuf[i]);
} else printf("%lld",(long long)num64);
printf(" PUSHDATA len.%d\n",numlen);*/
printf(" PUSHDATA len.%d\n",numlen);
if ( stacks->stackdepth < stacks->maxstackdepth )
{
if ( stacks->logarray != 0 )
@ -858,12 +858,21 @@ int32_t iguana_checklocktimeverify(struct iguana_info *coin,int64_t tx_lockval,u
{
int64_t nLockTime = iguana_num(Snum);
if ( nLockTime < 0 || tx_lockval < 0 )
{
printf("CLTV.0 nLockTime.%lld tx_lockval.%lld\n",(long long)nLockTime,(long long)tx_lockval);
return(-1);
}
else if ( ((tx_lockval < LOCKTIME_THRESHOLD && nLockTime < LOCKTIME_THRESHOLD) ||
(tx_lockval >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD)) == 0 )
{
printf("CLTV.1 nLockTime.%lld tx_lockval.%lld\n",(long long)nLockTime,(long long)tx_lockval);
return(-1);
}
else if ( nLockTime > tx_lockval )
{
printf("CLTV.2 nLockTime.%lld tx_lockval.%lld\n",(long long)nLockTime,(long long)tx_lockval);
return(-1);
}
return(0);
}
@ -1298,7 +1307,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
for (i=0; i<numargs; i++)
args[numargs - 1 - i] = iguana_pop(stacks);
}
//printf("%02x: numargs.%d depth.%d\n",op->opcode,numargs,stacks->stackdepth);
printf("%02x: numargs.%d depth.%d\n",op->opcode,numargs,stacks->stackdepth);
if ( stacks->logarray != 0 )
{
char tmpstr[1096];

21
iguana/iguana_sign.c

@ -1253,9 +1253,11 @@ cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t
int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLockTime,struct vin_info *V,int32_t numvins)
{
uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,errs = 0; cJSON *spendscript,*item;
uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript,savescript[IGUANA_MAXSCRIPTSIZE]; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,savelen,errs = 0; cJSON *spendscript,*item;
for (vini=0; vini<numvins; vini++)
{
savelen = V[vini].spendlen;
memcpy(savescript,V[vini].spendscript,savelen);
if ( V[vini].p2shlen > 0 )
{
activescript = V[vini].p2shscript;
@ -1266,12 +1268,15 @@ int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLoc
activescript = V[vini].spendscript;
activescriptlen = V[vini].spendlen;
}
memcpy(V[vini].spendscript,activescript,activescriptlen);
V[vini].spendlen = activescriptlen;
spendscript = iguana_spendasm(coin,activescript,activescriptlen);
if ( activescriptlen < 16 )
continue;
//printf("interpreter.(%s)\n",jprint(spendscript,0));
if ( (scriptlen= bitcoin_assembler(coin,logarray,script,spendscript,1,nLockTime,&V[vini])) < 0 )
{
printf("bitcoin_assembler error scriptlen.%d\n",scriptlen);
errs++;
}
else if ( scriptlen != activescriptlen || memcmp(script,activescript,scriptlen) != 0 )
@ -1280,14 +1285,22 @@ int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLoc
{
item = cJSON_CreateObject();
jaddstr(item,"error","script reconstruction failed");
init_hexbytes_noT(str,activescript,activescriptlen);
}
init_hexbytes_noT(str,activescript,activescriptlen);
printf("activescript.(%s)\n",str);
if ( logarray != 0 )
jaddstr(item,"original",str);
init_hexbytes_noT(str,script,scriptlen);
init_hexbytes_noT(str,script,scriptlen);
printf("reconstructed.(%s)\n",str);
if ( logarray != 0 )
{
jaddstr(item,"reconstructed",str);
jaddi(logarray,item);
} else printf(" scriptlen mismatch.%d vs %d or miscompare\n",scriptlen,activescriptlen);
//errs++;
errs++;
}
memcpy(V[vini].spendscript,savescript,savelen);
V[vini].spendlen = savelen;
}
if ( errs != 0 )
return(-errs);

Loading…
Cancel
Save