Browse Source

Test

etomic
jl777 8 years ago
parent
commit
5d7c34efa0
  1. 26
      iguana/iguana_sign.c

26
iguana/iguana_sign.c

@ -568,6 +568,22 @@ void iguana_vinobjset(struct iguana_msgvin *vin,cJSON *item,uint8_t *spendscript
}
}
int32_t iguana_vinarray_check(cJSON *vinarray,bits256 txid)
{
bits256 array_txid; cJSON *item; int32_t i,n = cJSON_GetArraySize(vinarray);
for (i=0; i<n; i++)
{
item = jitem(vinarray,i);
array_txid = jbits256(item,"txid");
if ( bits256_cmp(array_txid,txid) == 0 )
{
printf("vinarray.[%d] duplicate\n",i);
return(i);
}
}
return(-1);
}
int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJSON *json,uint8_t *serialized,int32_t maxsize,struct iguana_msgtx *msg,bits256 *txidp,char *vpnstr,uint8_t *extraspace,int32_t extralen,cJSON *vins,int32_t suppress_pubkeys)
{
int32_t i,n,len = 0,extraused=0; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE],*txstart = serialized,*sigser=0; char txidstr[65]; cJSON *vinarray=0,*voutarray=0; bits256 sigtxid;
@ -688,10 +704,12 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
iguana_vinobjset(&msg->vins[i],jitem(vins,i),spendscript,sizeof(spendscript));
sigtxid = bitcoin_sigtxid(coin,height,sigser,maxsize*2,msg,i,msg->vins[i].spendscript,msg->vins[i].spendlen,SIGHASH_ALL,vpnstr,suppress_pubkeys);
//printf("after vini.%d vinscript.%p spendscript.%p spendlen.%d (%s)\n",i,msg->vins[i].vinscript,msg->vins[i].spendscript,msg->vins[i].spendlen,jprint(jitem(vins,i),0));
jaddi(vinarray,iguana_vinjson(coin,&msg->vins[i],sigtxid));
if ( iguana_vinarray_check(vinarray,msg->vins[i].prev_hash) < 0 )
jaddi(vinarray,iguana_vinjson(coin,&msg->vins[i],sigtxid));
if ( msg->vins[i].spendscript == spendscript )
msg->vins[i].spendscript = 0;
} else jaddi(vinarray,iguana_vinjson(coin,&msg->vins[i],sigtxid));
} else if ( iguana_vinarray_check(vinarray,msg->vins[i].prev_hash) < 0 )
jaddi(vinarray,iguana_vinjson(coin,&msg->vins[i],sigtxid));
}
free(sigser);
jadd(json,"vin",vinarray);
@ -1359,7 +1377,7 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf
extraspace = malloc(extralen);
memset(msgtx,0,sizeof(*msgtx));
decode_hex(serialized,len,rawtx);
//printf("call hex2json.(%s) vins.(%s)\n",rawtx,jprint(vins,0));
printf("call hex2json.(%s) vins.(%s)\n",rawtx,jprint(vins,0));
if ( (txobj= bitcoin_hex2json(coin,height,&txid,msgtx,rawtx,extraspace,extralen,serialized4,vins,V->suppress_pubkeys)) != 0 )
{
printf("back from bitcoin_hex2json (%s)\n",jprint(vins,0));
@ -1368,7 +1386,7 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf
{
printf("numinputs.%d msgtx.%d\n",numinputs,msgtx->tx_in);
memset(msgtx,0,sizeof(*msgtx));
if ( iguana_rwmsgtx(coin,height,0,0,serialized,maxsize,msgtx,&txid,"",extraspace,65536,0,V->suppress_pubkeys) > 0 && numinputs == msgtx->tx_in )
if ( iguana_rwmsgtx(coin,height,0,0,serialized,maxsize,msgtx,&txid,"",extraspace,65536,vins,V->suppress_pubkeys) > 0 && numinputs == msgtx->tx_in )
{
printf("back rwmsgtx vins.%p\n",msgtx->vins);
memset(pubkeys,0,sizeof(pubkeys));

Loading…
Cancel
Save