Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
74b4f3c7da
  1. 11
      iguana/iguana_interpreter.c
  2. 27
      iguana/iguana_sign.c
  3. 2
      iguana/tests/decoderawtransaction

11
iguana/iguana_interpreter.c

@ -1128,6 +1128,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
}
else if ( n < 0 )
{
printf("dataparse negative n.%d\n",n);
errs++;
break;
}
@ -1172,7 +1173,10 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
else
{
if ( stacks->stackdepth <= 0 )
{
printf("if invalid stackdepth %d\n",stacks->stackdepth);
errs++;
}
else
{
args[0] = iguana_pop(stacks);
@ -1191,9 +1195,12 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
}
break;
case IGUANA_OP_ELSE:
if ( stacks->stackdepth <= 0 )
/*if ( stacks->stackdepth <= 0 )
{
printf("else invalid stackdepth %d\n",stacks->stackdepth);
errs++;
else
}
else*/
{
if ( stacks->ifdepth <= stacks->elsedepth )
{

27
iguana/iguana_sign.c

@ -38,12 +38,13 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
msg->vinscript = &serialized[len];
len += msg->scriptlen;
}
else if ( msg->vinscript != 0 && msg->scriptlen > 0 )
else
{
if ( msg->vinscript != 0 && msg->scriptlen > 0 )
memcpy(&serialized[len],msg->vinscript,msg->scriptlen), len += msg->scriptlen; // pubkeys here
if ( msg->userdatalen > 0 && msg->userdata != 0 )
{
printf("userdata.%d p2shlen %d %x\n",msg->userdatalen,msg->p2shlen,msg->p2shlen);
printf("userdata.%d p2shlen %d %x scriptlen.%d\n",msg->userdatalen,msg->p2shlen,msg->p2shlen,msg->scriptlen);
memcpy(&serialized[len],msg->userdata,msg->userdatalen);
len += msg->userdatalen;
}
@ -66,11 +67,11 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
}
}
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->sequence),&msg->sequence);
if ( 0 )
if ( 1 )
{
int32_t i; char str[65];
for (i=0; i<msg->scriptlen; i++)
printf("%02x",msg->vinscript[i]);
for (i=0; i<len; i++)
printf("%02x",serialized[i]);
printf(" prev_hash.(%s) vout.%d [%p] scriptlen.%d rwflag.%d\n",bits256_str(str,msg->prev_hash),msg->prev_vout,msg->vinscript,msg->scriptlen,rwflag);
}
return(len);
@ -722,6 +723,7 @@ int32_t iguana_msgtx_Vset(struct iguana_info *coin,uint8_t *serialized,int32_t m
scriptlen += siglen;
}
}
msgtx->vins[vini].scriptlen = scriptlen;
if ( vp->suppress_pubkeys == 0 && (vp->N > 1 || bitcoin_pubkeylen(&vp->spendscript[1]) != vp->spendscript[0] || vp->spendscript[vp->spendlen-1] != 0xac) )
{
for (j=0; j<vp->N; j++)
@ -733,10 +735,16 @@ int32_t iguana_msgtx_Vset(struct iguana_info *coin,uint8_t *serialized,int32_t m
scriptlen += plen;
}
}
msgtx->vins[vini].scriptlen = scriptlen;
}
printf("USERDATALEN.%d\n",vp->userdatalen);
printf("USERDATALEN.%d scriptlen.%d redeemlen.%d\n",vp->userdatalen,scriptlen,vp->p2shlen);
if ( vp->userdatalen != 0 )
memcpy(&script[scriptlen],vp->userdata,vp->userdatalen), scriptlen += vp->userdatalen;
{
memcpy(&script[scriptlen],vp->userdata,vp->userdatalen);
msgtx->vins[vini].userdata = &script[scriptlen];
msgtx->vins[vini].userdatalen = vp->userdatalen;
scriptlen += vp->userdatalen;
}
if ( (p2shlen= vp->p2shlen) > 0 )
{
msgtx->vins[vini].redeemscript = &script[scriptlen];
@ -753,9 +761,10 @@ int32_t iguana_msgtx_Vset(struct iguana_info *coin,uint8_t *serialized,int32_t m
script[scriptlen++] = (p2shlen & 0xff);
script[scriptlen++] = ((p2shlen >> 8) & 0xff);
} else return(-1);
memcpy(&script[scriptlen],vp->p2shscript,p2shlen), scriptlen += p2shlen;
memcpy(&script[scriptlen],vp->p2shscript,p2shlen);
scriptlen += p2shlen;
msgtx->vins[vini].p2shlen = p2shlen;
}
msgtx->vins[vini].scriptlen = scriptlen;
len += scriptlen;
}
return(len);

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"010000008497a857019cb804dc1c70059d45c8d135bd630b2be9fcd27dd6c9d5510aec0d25e43f734b01000000000000000002a0860100000000001976a914a3a0ee4fc2455ed9e1d57ef87dac45513f8a544188ac10bf1c05000000001976a91421e112f4211cbc612bc5f3de86acf0017b88b67d88ac00000000\", 1]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000080ada85701522d200c3b6d4333a86a68ba2720a9ad722a7dcb5b2dcf9f396d6c8446348a100000000092483045022100c636f237a1ed9437b7e228ff5e65ca08d514df6b0fe0b2a2e586a04f146370680220548238c13ff10c958a71d8be889d87baf5eae1cb703e0a869d91c919957c5b9801483045022100b94843c6dfa085fab09e11633f82a88f950af726a6545c5be82d5e50af294a8302207558a585f9b8ee11714524233ef6f288c1859c0bdcc7ce6469051e66777620ee01ffffffff01706f9800000000001976a91454a752f0d71b89d7c014ed0be29ca231c9546f9f88ac00000000\", 1]}"

Loading…
Cancel
Save