Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
4d22e86033
  1. 2
      iguana/iguana777.h
  2. 33
      iguana/iguana_ramchain.c
  3. 2
      iguana/iguana_scripts.c

2
iguana/iguana777.h

@ -483,7 +483,7 @@ struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],r
struct vin_info
{
struct iguana_msgvin vin;
int32_t M,N,validmask,spendlen,type,p2shlen; uint32_t sequence;
int32_t M,N,validmask,spendlen,type,p2shlen,numpubkeys,numsigs; uint32_t sequence;
struct vin_signer signers[16];
char coinaddr[65];
uint8_t rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE],p2shscript[IGUANA_MAXSCRIPTSIZE];

33
iguana/iguana_ramchain.c

@ -788,7 +788,7 @@ uint32_t iguana_ramchain_addspend(struct iguana_info *coin,RAMCHAIN_FUNC,bits256
struct iguana_spend *s; struct iguana_kvitem *ptr = 0; bits256 txid; struct vin_info V;
uint32_t spendind,unspentind,txidind=0,pkind,external=0,poffsets[16],checksequenceid;
uint8_t sigsbuf[16*74],_script[IGUANA_MAXSCRIPTSIZE]; uint64_t value = 0;
int32_t metalen,sigsize,pubkeysize,p2shsize,numpubs,numsigs,suffixlen,i,sigslen,checklen;
int32_t metalen,sigsize,pubkeysize,p2shsize,suffixlen,i,sigslen,checklen;
spendind = ramchain->H.spendind++;
s = &Sx[spendind];
pkind = unspentind = 0;
@ -892,35 +892,30 @@ uint32_t iguana_ramchain_addspend(struct iguana_info *coin,RAMCHAIN_FUNC,bits256
//printf(" parsed rmd160_0\n");
memset(sigsbuf,0,sizeof(sigsbuf));
memset(poffsets,0,sizeof(poffsets));
for (i=numpubs=numsigs=sigslen=0; i<V.N; i++)
for (i=sigslen=0; i<V.numsigs; i++)
{
if ( V.signers[i].pubkey[0] != 0 )
{
if ( (poffsets[i]= iguana_ramchain_pubkeyoffset(coin,RAMCHAIN_ARG,1,&ramchain->pkind,&ramchain->H.scriptoffset,V.signers[i].pubkey,V.signers[i].rmd160)) == 0 )
{
printf("addspend: error couldnt get pubkeyoffset\n");
} //else printf("poffset[%d] <- 0x%x (%02x %02x)\n",i,poffsets[i],Kspace[poffsets[i]],Kspace[poffsets[i]+32]);
numpubs++;
}
if ( V.signers[i].siglen > 0 )
{
sigsbuf[sigslen++] = V.signers[i].siglen;
memcpy(&sigsbuf[sigslen],V.signers[i].sig,V.signers[i].siglen);
sigslen += V.signers[i].siglen;
numsigs++;
}
}
s->numsigs = numsigs;
s->numpubkeys = numpubs;
if ( vinscriptlen-71*numsigs < numpubs*33 )
for (i=0; i<V.numpubkeys; i++)
{
for (i=0; i<vinscriptlen; i++)
printf("%02x",vinscript[i]);
printf(" vinscript numsigs.%d numpubs.%d vinscriptlen.%d?\n",numsigs,numpubs,vinscriptlen);
if ( V.signers[i].pubkey[0] != 0 )
{
if ( (poffsets[i]= iguana_ramchain_pubkeyoffset(coin,RAMCHAIN_ARG,1,&ramchain->pkind,&ramchain->H.scriptoffset,V.signers[i].pubkey,V.signers[i].rmd160)) == 0 )
{
printf("addspend: error couldnt get pubkeyoffset\n");
} //else printf("poffset[%d] <- 0x%x (%02x %02x)\n",i,poffsets[i],Kspace[poffsets[i]],Kspace[poffsets[i]+32]);
}
}
s->numsigs = V.numsigs;
s->numpubkeys = V.numpubkeys;
if ( p2shsize != 0 )
s->p2sh = 1;
if ( sigslen+numsigs+numpubs+suffixlen != 0 || s->sequenceid == 3 )
if ( sigslen+V.numsigs+V.numpubkeys+suffixlen != 0 || s->sequenceid == 3 )
{
ramchain->H.stacksize += sigslen;
checklen = iguana_vinscriptencode(coin,&Kspace[ramchain->H.data->scriptspace],ramchain->H.stacksize,Kspace,ramchain->H.scriptoffset,s,sequence,sigsbuf,sigslen,poffsets,V.p2shscript,V.p2shlen,&vinscript[vinscriptlen-suffixlen],suffixlen);
@ -936,7 +931,7 @@ uint32_t iguana_ramchain_addspend(struct iguana_info *coin,RAMCHAIN_FUNC,bits256
printf(" vinscript\n");
printf("addspend: vinscript expand error (%d vs %d) %d seq.(%u %u)\n",checklen,vinscriptlen,memcmp(_script,vinscript,vinscriptlen),sequence,checksequenceid);
} else s->coinbase = 1;//, printf("vin reconstructed metalen.%d vinlen.%d\n",metalen,checklen);
} else printf("sigslen.%d numsigs.%d numpubs.%d suffixlen.%d\n",sigslen,numsigs,numpubs,suffixlen);
} else printf("sigslen.%d numsigs.%d numpubs.%d suffixlen.%d\n",sigslen,V.numsigs,V.numpubkeys,suffixlen);
//s->hdrsi = hdrsi;
//s->bundlei = bundlei;
//char str[65]; printf("%s set prevout.%d -> %d\n",bits256_str(str,prev_hash),prev_vout,s->prevout);

2
iguana/iguana_scripts.c

@ -701,6 +701,7 @@ int32_t bitcoin_scriptget(struct iguana_info *coin,int32_t *hashtypep,int32_t *s
if ( spendtype == 0 && j > 1 )
spendtype = IGUANA_SCRIPT_MSIG;
}
vp->numsigs = j;
vp->type = spendtype;
if ( j == 0 )
{
@ -719,6 +720,7 @@ int32_t bitcoin_scriptget(struct iguana_info *coin,int32_t *hashtypep,int32_t *s
(*pubkeysizep) += plen;
j++;
}
vp->numpubkeys = j;
if ( n < len && (scriptsig[n] == 0x4c || scriptsig[n] == 0x4d) )
{
if ( scriptsig[n] == 0x4c )

Loading…
Cancel
Save