jl777 8 years ago
parent
commit
0d579d2ea8
  1. 30
      iguana/iguana_interpreter.c

30
iguana/iguana_interpreter.c

@ -1337,38 +1337,32 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
}
else if ( (op->flags & IGUANA_CRYPTOFLAG) != 0 )
{
uint8_t rmd160[20]; bits256 hash; //,revrmd160[20]; bits256 hash,revhash;
datalen = iguana_databuf(databuf,args[0]);
uint8_t rmd160[20],revdata[0x100]; bits256 hash;
if ( (datalen= iguana_databuf(databuf,args[0])) <= sizeof(revdata) )
{
for (i=0; i<datalen; i++)
revdata[i] = databuf[datalen-1-i];
} else printf("datalen.%d too big for %d\n",datalen,(int32_t)sizeof(revdata));
switch ( op->opcode )
{
case IGUANA_OP_RIPEMD160:
calc_rmd160(0,rmd160,databuf,datalen);
//for (i=0; i<20; i++)
// rmd160[i] = revrmd160[19-i];
calc_rmd160(0,rmd160,revdata,datalen);
iguana_pushdata(stacks,0,rmd160,sizeof(rmd160));
break;
case IGUANA_OP_SHA1:
calc_sha1(0,rmd160,databuf,datalen);
//for (i=0; i<20; i++)
// rmd160[i] = revrmd160[19-i];
calc_sha1(0,rmd160,revdata,datalen);
iguana_pushdata(stacks,0,rmd160,sizeof(rmd160));
break;
case IGUANA_OP_HASH160:
calc_rmd160_sha256(rmd160,databuf,datalen);
//for (i=0; i<20; i++)
// rmd160[i] = revrmd160[19-i];
iguana_pushdata(stacks,0,rmd160,sizeof(rmd160));
calc_rmd160_sha256(rmd160,revdata,datalen);
iguana_pushdata(stacks,0,rmd160,sizeof(rmd160));
break;
case IGUANA_OP_SHA256:
vcalc_sha256(0,hash.bytes,databuf,datalen);
//for (i=0; i<32; i++)
// hash.bytes[i] = revhash.bytes[31-i];
vcalc_sha256(0,hash.bytes,revdata,datalen);
iguana_pushdata(stacks,0,hash.bytes,sizeof(hash));
break;
case IGUANA_OP_HASH256:
hash = bits256_doublesha256(0,databuf,datalen);
//for (i=0; i<32; i++)
// hash.bytes[i] = revhash.bytes[31-i];
hash = bits256_doublesha256(0,revdata,datalen);
iguana_pushdata(stacks,0,hash.bytes,sizeof(hash));
break;
case IGUANA_OP_CHECKSIG: case IGUANA_OP_CHECKSIGVERIFY:

Loading…
Cancel
Save