Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
94edf0a790
  1. 1
      iguana/exchanges/bitcoin.h
  2. 15
      iguana/iguana_ramchain.c
  3. 2
      iguana/iguana_recv.c
  4. 24
      iguana/iguana_scripts.c

1
iguana/exchanges/bitcoin.h

@ -55,6 +55,7 @@
#define IGUANA_SCRIPT_1of2 9
#define IGUANA_SCRIPT_MSIG 10
#define IGUANA_SCRIPT_DATA 11
#define IGUANA_SCRIPT_AC 12
#define IGUANA_SCRIPT_STRANGE 15
#define IGUANA_MAXSCRIPTSIZE 10001

15
iguana/iguana_ramchain.c

@ -317,13 +317,16 @@ uint32_t iguana_ramchain_addunspent20(struct iguana_info *coin,struct iguana_pee
{
memset(&V,0,sizeof(V));
V.spendlen = iguana_scriptgen(coin,&V.M,&V.N,V.coinaddr,V.spendscript,asmstr,u->rmd160,type,(const struct vin_info *)&V,vout);
if ( (V.spendlen != scriptlen || memcmp(V.spendscript,script,scriptlen) != 0) && addr != 0 && addr->voutsfp != 0 )
if ( V.spendlen != scriptlen || memcmp(V.spendscript,script,scriptlen) != 0 )
{
u->fileid = (uint32_t)addr->addrind;
u->scriptpos = (uint32_t)ftell(addr->voutsfp);
if ( fwrite(script,1,scriptlen,addr->voutsfp) != scriptlen )
printf("error writing vout scriptlen.%d errno.%d\n",scriptlen,errno);
else addr->dirty[0]++;
if ( addr != 0 && addr->voutsfp != 0 )
{
u->fileid = (uint32_t)addr->addrind;
u->scriptpos = (uint32_t)ftell(addr->voutsfp);
if ( fwrite(script,1,scriptlen,addr->voutsfp) != scriptlen )
printf("error writing vout scriptlen.%d errno.%d\n",scriptlen,errno);
else addr->dirty[0]++;
} else printf("addr.%p unspent error fp.%p\n",addr,addr!=0?addr->voutsfp:0);
}
else
{

2
iguana/iguana_recv.c

@ -341,7 +341,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
if ( coin->bandwidth < 0.25*coin->maxbandwidth )
{
//printf(">>SLOW.%d<< ",addr->addrind);
iguana_blast(coin,addr);
//iguana_blast(coin,addr);
}
}
copyflag = 0;//(coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);

24
iguana/iguana_scripts.c

@ -471,11 +471,16 @@ int32_t iguana_scriptgen(struct iguana_info *coin,int32_t *Mp,int32_t *nump,char
coinaddr[0] = 0;
break;
case IGUANA_SCRIPT_76AC:
case IGUANA_SCRIPT_AC:
if ( (plen= bitcoin_pubkeylen(vp->signers[0].pubkey)) < 0 )
return(0);
init_hexbytes_noT(pubkeystr,(uint8_t *)vp->signers[0].pubkey,plen);
if ( asmstr != 0 )
sprintf(asmstr,"OP_DUP %s OP_CHECKSIG // %s",pubkeystr,coinaddr);
{
if ( type == IGUANA_SCRIPT_76AC )
strcpy(asmstr,"OP_DUP ");
sprintf(asmstr + strlen(asmstr),"%s OP_CHECKSIG // %s",pubkeystr,coinaddr);
}
scriptlen = bitcoin_pubkeyspend(script,0,(uint8_t *)vp->signers[0].pubkey);
//printf("[%02x] scriptlen.%d (%s)\n",vp->signers[0].pubkey[0],scriptlen,asmstr);
break;
@ -590,6 +595,12 @@ int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp)
calc_rmd160_sha256(vp->rmd160,vp->signers[0].pubkey,vp->spendscript[0]);
return(IGUANA_SCRIPT_76AC);
}
else if ( vp->spendscript[0] > 0 && vp->spendscript[0] < 76 && vp->spendscript[vp->spendlen-1] == SCRIPT_OP_CHECKSIG && vp->spendscript[0] == vp->spendlen-1 && bitcoin_pubkeylen(&vp->spendscript[1]) > 0 )
{
memcpy(vp->signers[0].pubkey,&vp->spendscript[0],vp->spendscript[0]);
calc_rmd160_sha256(vp->rmd160,vp->signers[0].pubkey,vp->spendscript[0]);
return(IGUANA_SCRIPT_AC);
}
else if ( vp->spendscript[0] == SCRIPT_OP_HASH160 && vp->spendscript[1] == 0x14 && vp->spendlen == 23 && vp->spendscript[22] == SCRIPT_OP_EQUAL )
{
memcpy(vp->rmd160,vp->spendscript+2,20);
@ -1226,13 +1237,14 @@ uint8_t *iguana_ramchain_scriptdecode(int32_t *metalenp,int32_t *scriptlenp,uint
{
uint32_t plen,len = 0;
*metalenp = *scriptlenp = 0;
if ( type == IGUANA_SCRIPT_76AC && pubkeyoffset != 0 )
if ( (type == IGUANA_SCRIPT_76AC || type == IGUANA_SCRIPT_AC) && pubkeyoffset != 0 )
{
plen = bitcoin_pubkeylen(&Kspace[pubkeyoffset]);
_script[0] = 0x76;
memcpy(&_script[1],&Kspace[pubkeyoffset],plen);
_script[plen + 1] = 0xac;
*scriptlenp = plen + 2;
if ( type == IGUANA_SCRIPT_76AC )
_script[len++] = 0x76;
memcpy(&_script[len],&Kspace[pubkeyoffset],plen);
_script[plen + len] = 0xac;
*scriptlenp = plen + len;
//printf("76AC special case\n");
return(_script);
}

Loading…
Cancel
Save