Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
26e6364580
  1. 2
      basilisk/basilisk_bitcoin.c
  2. 6
      iguana/iguana777.h
  3. 2
      iguana/iguana_accept.c
  4. 21
      iguana/iguana_chains.c
  5. 4
      iguana/iguana_init.c
  6. 12
      iguana/iguana_msg.c
  7. 4
      iguana/iguana_tx.c
  8. 4
      iguana/main.c

2
basilisk/basilisk_bitcoin.c

@ -234,7 +234,7 @@ int32_t basilisk_bitcoinscan(struct iguana_info *coin,uint8_t origblockspace[IGU
//printf(" B.%s\n",bits256_str(str,checkhash2));
msg = (void *)blockspace;
//printf("(%s)\n",jprint(blockjson,0));
checkhash2 = iguana_calcblockhash(coin->chain->hashalgo,blockspace,sizeof(*msg)-4);
checkhash2 = iguana_calcblockhash(coin->symbol,coin->chain->hashalgo,blockspace,sizeof(*msg)-4);
if ( jstr(blockjson,"hash") != 0 )
hash2 = bits256_conv(jstr(blockjson,"hash"));
else memset(hash2.bytes,0,sizeof(hash2));

6
iguana/iguana777.h

@ -588,7 +588,7 @@ int32_t iguana_rwmem(int32_t rwflag,uint8_t *serialized,int32_t len,void *endian
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t iguana_rwvarint32(int32_t rwflag,uint8_t *serialized,uint32_t *int32p);
int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
int32_t iguana_rwblock(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),int32_t rwflag,bits256 *hash2p,uint8_t *serialized,struct iguana_msgblock *msg);
int32_t iguana_rwblock(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),int32_t rwflag,bits256 *hash2p,uint8_t *serialized,struct iguana_msgblock *msg);
int32_t iguana_serialize_block(struct iguana_chain *chain,bits256 *hash2p,uint8_t serialized[sizeof(struct iguana_msgblock)],struct iguana_block *block);
void iguana_blockconv(struct iguana_block *dest,struct iguana_msgblock *msg,bits256 hash2,int32_t height);
//void iguana_freetx(struct iguana_msgtx *tx,int32_t n);
@ -819,7 +819,7 @@ int32_t SuperNET_sendmsg(struct supernet_info *myinfo,struct iguana_info *coin,s
int32_t category_peer(struct supernet_info *myinfo,struct iguana_peer *addr,bits256 category,bits256 subhash);
int32_t bitcoin_wif2priv(uint8_t *addrtypep,bits256 *privkeyp,char *wifstr);
int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype);
bits256 iguana_chaingenesis(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),bits256 genesishash,char *genesisblock,char *hashalgostr,int32_t version,uint32_t timestamp,uint32_t bits,uint32_t nonce,bits256 merkle_root);
bits256 iguana_chaingenesis(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),bits256 genesishash,char *genesisblock,char *hashalgostr,int32_t version,uint32_t timestamp,uint32_t bits,uint32_t nonce,bits256 merkle_root);
int32_t iguana_send_ConnectTo(struct iguana_info *coin,struct iguana_peer *addr);
cJSON *iguana_txjson(struct iguana_info *coin,struct iguana_txid *tx,int32_t height,struct vin_info *V);
char *iguana_txscan(struct iguana_info *coin,cJSON *json,uint8_t *data,int32_t recvlen,bits256 txid);
@ -1004,7 +1004,7 @@ void iguana_unspentslock(struct supernet_info *myinfo,struct iguana_info *coin,c
char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf);
char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey);
bits256 scrypt_blockhash(const void *input);
bits256 iguana_calcblockhash(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len);
bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len);
uint32_t iguana_targetbits(struct iguana_info *coin,struct iguana_block *hwmchain,struct iguana_block *prev,struct iguana_block *prev2,int32_t PoSflag);
struct bitcoin_eventitem *instantdex_event(char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen);
void instantdex_eventfree(struct bitcoin_eventitem *ptr);

2
iguana/iguana_accept.c

@ -298,7 +298,7 @@ int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32
if ( (block= bp->blocks[i]) != 0 )
{
iguana_blockunconv(&msgB,block,1);
len += iguana_rwblock(coin->chain->hashalgo,1,&checkhash2,&serialized[sizeof(struct iguana_msghdr) + len],&msgB);
len += iguana_rwblock(coin->symbol,coin->chain->hashalgo,1,&checkhash2,&serialized[sizeof(struct iguana_msghdr) + len],&msgB);
flag++;
if ( bits256_cmp(checkhash2,block->RO.hash2) != 0 )
{

21
iguana/iguana_chains.c

@ -124,7 +124,7 @@ blockhashfunc iguana_hashalgo(char *hashalgostr)
return(0);
}
bits256 iguana_calcblockhash(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len)
bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len)
{
bits256 tmp,hash2; int32_t i;
memset(&hash2,0,sizeof(hash2));
@ -135,10 +135,23 @@ bits256 iguana_calcblockhash(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *se
for (i=0; i<32; i++)
hash2.bytes[i] = tmp.bytes[31 - i];
} else return(tmp);
if ( hashalgo == blockhash_scrypt )
{
char str[65]; bits256 checkhash2; struct iguana_msgblock msg; struct iguana_block *block; struct iguana_info *coin;
if ( (coin= iguana_coinfind(symbol)) != 0 )
{
iguana_rwblock(symbol,hashalgo,0,&checkhash2,serialized,&msg);
if ( (block= iguana_blockfind("hashalgo",coin,msg.H.prev_block)) != 0 )
{
hash2 = iguana_blockhash(coin,block->height+1);
printf("sethash2.(%s)\n",bits256_str(str,hash2));
}
}
}
return(hash2);
}
bits256 iguana_chaingenesis(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),bits256 genesishash,char *genesisblock,char *hashalgostr,int32_t version,uint32_t timestamp,uint32_t nBits,uint32_t nonce,bits256 merkle_root)
bits256 iguana_chaingenesis(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),bits256 genesishash,char *genesisblock,char *hashalgostr,int32_t version,uint32_t timestamp,uint32_t nBits,uint32_t nonce,bits256 merkle_root)
{
struct iguana_msgblock msg; int32_t len; bits256 hash2; char blockhashstr[256],str3[65]; uint8_t serialized[1024];
memset(&msg,0,sizeof(msg));
@ -150,7 +163,7 @@ bits256 iguana_chaingenesis(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *ser
if ( hashalgostr != 0 && strcmp(hashalgostr,"sha256") != 0 )
hashalgo = iguana_hashalgo(hashalgostr);
else hashalgo = blockhash_sha256;
len = iguana_rwblock(hashalgo,1,&hash2,serialized,&msg);
len = iguana_rwblock(symbol,hashalgo,1,&hash2,serialized,&msg);
blockhashstr[0] = 0;
init_hexbytes_noT(blockhashstr,hash2.bytes,sizeof(hash2));
char str[65],str2[65];
@ -329,7 +342,7 @@ void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson)
((uint8_t *)&nBits)[3] = tmp[0];
}
else nBits = 0x1e00ffff;
hash = iguana_chaingenesis(chain->hashalgo,hash,genesisblock,jstr(genesis,"hashalgo"),juint(genesis,"version"),juint(genesis,"timestamp"),nBits,juint(genesis,"nonce"),jbits256(genesis,"merkle_root"));
hash = iguana_chaingenesis(chain->symbol,chain->hashalgo,hash,genesisblock,jstr(genesis,"hashalgo"),juint(genesis,"version"),juint(genesis,"timestamp"),nBits,juint(genesis,"nonce"),jbits256(genesis,"merkle_root"));
//chain->genesis_hash = clonestr(bits256_str(str,hash));
chain->genesis_hex = clonestr(genesisblock);
}

4
iguana/iguana_init.c

@ -85,8 +85,8 @@ bits256 iguana_genesis(struct iguana_info *coin,struct iguana_chain *chain)
return(hash2);
}
decode_hex(buf,(int32_t)strlen(chain->genesis_hex)/2,(char *)chain->genesis_hex);
hash2 = iguana_calcblockhash(coin->chain->hashalgo,buf,sizeof(struct iguana_msgblockhdr));
iguana_rwblock(coin->chain->hashalgo,0,&hash2,buf,&msg);
hash2 = iguana_calcblockhash(coin->symbol,coin->chain->hashalgo,buf,sizeof(struct iguana_msgblockhdr));
iguana_rwblock(coin->symbol,coin->chain->hashalgo,0,&hash2,buf,&msg);
if ( coin->MAXPEERS > 1 && memcmp(hash2.bytes,chain->genesis_hashdata,sizeof(hash2)) != 0 )
{
bits256_str(str,hash2);

12
iguana/iguana_msg.c

@ -78,7 +78,7 @@ int32_t iguana_rwversion(int32_t rwflag,uint8_t *serialized,struct iguana_msgver
// 06000000996da490f6151ad9d05d9defc99bda58441d2b833c0da69d11e764d7c70a00003378a650b506a66b41097a0b513f2fee899788711bc6643ff976ce6dbb0b620c5f800854ffff0f1e0004de0301010000005e800854010000000000000000000000000000000000000000000000000000000000000000ffffffff03510102ffffffff0100008a5d784563011976a9145166e6e52de58dfacb18670c0030aedcf295233988ac000000000000
int32_t iguana_rwblock(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),int32_t rwflag,bits256 *hash2p,uint8_t *serialized,struct iguana_msgblock *msg)
int32_t iguana_rwblock(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),int32_t rwflag,bits256 *hash2p,uint8_t *serialized,struct iguana_msgblock *msg)
{
int32_t len = 0; uint64_t x;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->H.version),&msg->H.version);
@ -87,7 +87,7 @@ int32_t iguana_rwblock(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serializ
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->H.timestamp),&msg->H.timestamp);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->H.bits),&msg->H.bits);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->H.nonce),&msg->H.nonce);
*hash2p = iguana_calcblockhash(hashalgo,serialized,len);
*hash2p = iguana_calcblockhash(symbol,hashalgo,serialized,len);
//char str[65]; printf("len.%d: block version.%d timestamp.%u bits.%x nonce.%u prev.(%s) %llx blockhash.(%s) %llx\n",len,msg->H.version,msg->H.timestamp,msg->H.bits,msg->H.nonce,bits256_str(str,msg->H.prev_block),(long long)msg->H.merkle_root.txid,blockhash,(long long)hash2p->txid);
if ( rwflag != 0 )
x = msg->txn_count;
@ -115,7 +115,7 @@ int32_t iguana_serialize_block(struct iguana_chain *chain,bits256 *hash2p,uint8_
msg.H.bits = block->RO.bits;
msg.H.nonce = block->RO.nonce;
msg.txn_count = block->RO.txn_count;
len = iguana_rwblock(chain->hashalgo,1,hash2p,serialized,&msg);
len = iguana_rwblock(chain->symbol,chain->hashalgo,1,hash2p,serialized,&msg);
return(len);
}
@ -425,7 +425,7 @@ char *iguana_txscan(struct iguana_info *coin,cJSON *json,uint8_t *data,int32_t r
memset(&msg,0,sizeof(msg));
vpnstr[0] = 0;
extraspace = calloc(1,extralen);
len = iguana_rwblock(coin->chain->hashalgo,0,&hash2,data,&msg);
len = iguana_rwblock(coin->symbol,coin->chain->hashalgo,0,&hash2,data,&msg);
iguana_blockconv(&block,&msg,hash2,-1);
for (i=0; i<msg.txn_count; i++)
{
@ -451,7 +451,7 @@ int32_t iguana_gentxarray(struct iguana_info *coin,struct OS_memspace *mem,struc
{
struct iguana_msgtx *tx; bits256 hash2; struct iguana_msgblock msg; int32_t i,n,len,numvouts,numvins;
memset(&msg,0,sizeof(msg));
len = iguana_rwblock(coin->chain->hashalgo,0,&hash2,data,&msg);
len = iguana_rwblock(coin->symbol,coin->chain->hashalgo,0,&hash2,data,&msg);
iguana_blockconv(&txdata->block,&msg,hash2,-1);
tx = iguana_memalloc(mem,msg.txn_count*sizeof(*tx),1);
for (i=numvins=numvouts=0; i<msg.txn_count; i++)
@ -679,7 +679,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
blocks = mycalloc('i',1,sizeof(*blocks) * n);
for (i=0; i<n; i++)
{
len += iguana_rwblock(coin->chain->hashalgo,0,&hash2,&data[len],&msg);
len += iguana_rwblock(coin->symbol,coin->chain->hashalgo,0,&hash2,&data[len],&msg);
iguana_blockconv(&blocks[i],&msg,hash2,-1);
}
iguana_gotheadersM(coin,addr,blocks,n);

4
iguana/iguana_tx.c

@ -230,7 +230,7 @@ int32_t iguana_peerblockrequest(struct iguana_info *coin,uint8_t *blockspace,int
{
iguana_blockunconv(&msgB,block,0);
msgB.txn_count = block->RO.txn_count;
total = iguana_rwblock(coin->chain->hashalgo,1,&checkhash2,&blockspace[sizeof(struct iguana_msghdr) + 0],&msgB);
total = iguana_rwblock(coin->symbol,coin->chain->hashalgo,1,&checkhash2,&blockspace[sizeof(struct iguana_msghdr) + 0],&msgB);
if ( bits256_cmp(checkhash2,block->RO.hash2) != 0 )
{
static int counter;
@ -368,7 +368,7 @@ cJSON *iguana_blockjson(struct iguana_info *coin,struct iguana_block *block,int3
msg.H.bits = block->RO.bits;
msg.H.nonce = block->RO.nonce;
msg.txn_count = 0;//block->RO.txn_count;
len = iguana_rwblock(coin->chain->hashalgo,1,&hash2,serialized,&msg);
len = iguana_rwblock(coin->symbol,coin->chain->hashalgo,1,&hash2,serialized,&msg);
init_hexbytes_noT(hexstr,serialized,len);
jaddstr(json,"blockheader",hexstr);
if ( txidsflag != 0 )

4
iguana/main.c

@ -1151,9 +1151,9 @@ void iguana_appletests(struct supernet_info *myinfo)
if ( 0 )
{
char genesisblock[1024];
iguana_chaingenesis(0,bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99"),genesisblock,"scrypt",1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN
iguana_chaingenesis("VPN",0,bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99"),genesisblock,"scrypt",1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN
iguana_chaingenesis(0,bits256_conv("12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2"),genesisblock,"scrypt",1,1317972665,0x1e0ffff0,2084524493,bits256_conv("97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); // LTC
iguana_chaingenesis("LTC",0,bits256_conv("12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2"),genesisblock,"scrypt",1,1317972665,0x1e0ffff0,2084524493,bits256_conv("97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9")); // LTC
getchar();
}
if ( 1 )

Loading…
Cancel
Save