|
|
@ -967,6 +967,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
free(stacks); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
printf("pushdata siglen.%d depth.%d\n",V->signers[i].siglen,stacks->stackdepth); |
|
|
|
} |
|
|
|
} |
|
|
|
for (i=0; i<V->N; i++) |
|
|
@ -975,7 +976,10 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
{ |
|
|
|
plen = bitcoin_pubkeylen(V->signers[i].pubkey); |
|
|
|
if ( V->suppress_pubkeys == 0 && (V->spendscript[0] != plen || V->spendscript[V->spendlen - 1] != IGUANA_OP_CHECKSIG || bitcoin_pubkeylen(&V->spendscript[1]) <= 0) ) |
|
|
|
{ |
|
|
|
iguana_pushdata(stacks,0,V->signers[i].pubkey,plen); |
|
|
|
printf("pushdata plen.%d depth.%d\n",plen,stacks->stackdepth); |
|
|
|
} else printf("skip pubkey push %d script[0].%d spendlen.%d depth.%d\n",plen,V->spendscript[0],V->spendlen,stacks->stackdepth); |
|
|
|
} |
|
|
|
} |
|
|
|
if ( V->userdatalen != 0 ) |
|
|
@ -1113,37 +1117,6 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
} |
|
|
|
memset(args,0,sizeof(args)); |
|
|
|
numargs = 0; |
|
|
|
if ( op->opcode <= IGUANA_OP_16 || ++numops <= MAX_OPS_PER_SCRIPT ) |
|
|
|
{ |
|
|
|
script[k++] = op->opcode; |
|
|
|
if ( (op->flags & IGUANA_ALWAYSILLEGAL) != 0 ) |
|
|
|
{ |
|
|
|
printf("disabled opcode.%s at offset.%ld\n",str,(long)str-(long)asmstr); |
|
|
|
errs++; |
|
|
|
break; |
|
|
|
} |
|
|
|
else if ( op->extralen > 0 ) |
|
|
|
{ |
|
|
|
if ( is_delim(*str) != 0 ) |
|
|
|
str++; |
|
|
|
if ( is_hexstr(str,0) != (op->extralen<<1) ) |
|
|
|
{ |
|
|
|
printf("expected extralen.%d of hex, got.(%s) at offset.%ld\n",op->extralen,str,(long)str-(long)asmstr); |
|
|
|
errs++; |
|
|
|
break; |
|
|
|
} |
|
|
|
decode_hex(&script[k],op->extralen,str), str += (op->extralen << 1); |
|
|
|
if ( op->extralen == 1 ) |
|
|
|
iguana_pushdata(stacks,script[k],0,0); |
|
|
|
else if ( op->extralen == 2 ) |
|
|
|
iguana_pushdata(stacks,script[k] + ((uint32_t)script[k]<<8),0,0); |
|
|
|
k += op->extralen; |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ( interpret == 0 || V == 0 ) |
|
|
|
continue; |
|
|
|
if ( (op->flags & IGUANA_NOPFLAG) != 0 ) |
|
|
|
continue; |
|
|
|
if ( (op->flags & IGUANA_CONTROLFLAG) != 0 ) |
|
|
|
{ |
|
|
|
printf("control opcode depth.%d\n",stacks->stackdepth); |
|
|
@ -1201,9 +1174,9 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
printf("OP_ENDIF status.%d depth.%d\n",stacks->lastpath[stacks->ifdepth],stacks->stackdepth); |
|
|
|
break; |
|
|
|
case IGUANA_OP_VERIFY: |
|
|
|
if ( stacks->stackdepth > 0 ) |
|
|
|
args[0] = iguana_pop(stacks); |
|
|
|
else errs++; |
|
|
|
//if ( stacks->stackdepth > 0 )
|
|
|
|
// args[0] = iguana_pop(stacks);
|
|
|
|
//else errs++;
|
|
|
|
break; |
|
|
|
case IGUANA_OP_RETURN: |
|
|
|
iguana_pushdata(stacks,0,0,0); |
|
|
@ -1214,8 +1187,48 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
break; |
|
|
|
continue; |
|
|
|
} |
|
|
|
else if ( stacks->lastpath[stacks->ifdepth] >= 0 ) |
|
|
|
if ( stacks->lastpath[stacks->ifdepth] != 0 ) |
|
|
|
{ |
|
|
|
if ( stacks->lastpath[stacks->ifdepth] < 0 ) |
|
|
|
{ |
|
|
|
printf("SKIP opcode.%02x depth.%d\n",op->opcode,stacks->stackdepth); |
|
|
|
if ( stacks->logarray ) |
|
|
|
jaddistr(stacks->logarray,"skip"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
printf("conditional opcode.%02x stackdepth.%d\n",op->opcode,stacks->stackdepth); |
|
|
|
} |
|
|
|
if ( op->opcode <= IGUANA_OP_16 || ++numops <= MAX_OPS_PER_SCRIPT ) |
|
|
|
{ |
|
|
|
script[k++] = op->opcode; |
|
|
|
if ( (op->flags & IGUANA_ALWAYSILLEGAL) != 0 ) |
|
|
|
{ |
|
|
|
printf("disabled opcode.%s at offset.%ld\n",str,(long)str-(long)asmstr); |
|
|
|
errs++; |
|
|
|
break; |
|
|
|
} |
|
|
|
else if ( op->extralen > 0 ) |
|
|
|
{ |
|
|
|
if ( is_delim(*str) != 0 ) |
|
|
|
str++; |
|
|
|
if ( is_hexstr(str,0) != (op->extralen<<1) ) |
|
|
|
{ |
|
|
|
printf("expected extralen.%d of hex, got.(%s) at offset.%ld\n",op->extralen,str,(long)str-(long)asmstr); |
|
|
|
errs++; |
|
|
|
break; |
|
|
|
} |
|
|
|
decode_hex(&script[k],op->extralen,str), str += (op->extralen << 1); |
|
|
|
if ( op->extralen == 1 ) |
|
|
|
iguana_pushdata(stacks,script[k],0,0); |
|
|
|
else if ( op->extralen == 2 ) |
|
|
|
iguana_pushdata(stacks,script[k] + ((uint32_t)script[k]<<8),0,0); |
|
|
|
k += op->extralen; |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ( interpret == 0 || V == 0 ) |
|
|
|
continue; |
|
|
|
if ( (op->flags & IGUANA_NOPFLAG) != 0 ) |
|
|
|
continue; |
|
|
|
if ( (numargs= op->stackitems) > 0 ) |
|
|
|
{ |
|
|
|
if ( stacks->stackdepth < op->stackitems ) |
|
|
@ -1228,7 +1241,6 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
args[numargs - 1 - i] = iguana_pop(stacks); |
|
|
|
} |
|
|
|
printf("%02x: numargs.%d depth.%d\n",op->opcode,numargs,stacks->stackdepth); |
|
|
|
} |
|
|
|
if ( stacks->logarray != 0 ) |
|
|
|
{ |
|
|
|
char tmpstr[1096]; |
|
|
@ -1243,18 +1255,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
jadd(item,(char *)op->hh.key,array); |
|
|
|
jaddi(stacks->logarray,item); |
|
|
|
} |
|
|
|
if ( stacks->lastpath[stacks->ifdepth] != 0 ) |
|
|
|
{ |
|
|
|
if ( stacks->lastpath[stacks->ifdepth] < 0 ) |
|
|
|
{ |
|
|
|
printf("SKIP opcode.%02x depth.%d\n",op->opcode,stacks->stackdepth); |
|
|
|
if ( stacks->logarray ) |
|
|
|
jaddistr(stacks->logarray,"skip"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
printf("conditional opcode.%02x stackdepth.%d\n",op->opcode,stacks->stackdepth); |
|
|
|
} |
|
|
|
else if ( (op->flags & IGUANA_EXECUTIONILLEGAL) != 0 ) |
|
|
|
if ( (op->flags & IGUANA_EXECUTIONILLEGAL) != 0 ) |
|
|
|
{ |
|
|
|
printf("opcode not allowed to run.%s at %ld\n",(char *)op->hh.key,(long)str-(long)asmstr); |
|
|
|
errs++; |
|
|
@ -1381,7 +1382,11 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip |
|
|
|
iguana_stack(stacks,args,0,"","0"); |
|
|
|
iguana_stack(stacks,args,1,"0",""); |
|
|
|
break; |
|
|
|
case IGUANA_OP_DUP: iguana_stack(stacks,args,1,"0","0"); break; |
|
|
|
case IGUANA_OP_DUP: |
|
|
|
printf("before dup stackdepth.%d\n",stacks->stackdepth); |
|
|
|
iguana_stack(stacks,args,1,"0","0"); |
|
|
|
printf("after dup stackdepth.%d\n",stacks->stackdepth); |
|
|
|
break; |
|
|
|
case IGUANA_OP_2DUP: iguana_stack(stacks,args,2,"01","01"); break; |
|
|
|
case IGUANA_OP_NIP: |
|
|
|
if ( args[0].data != 0 ) |
|
|
|