Browse Source

test

etomic
jl777 8 years ago
parent
commit
abbcce6dd6
  1. 1
      iguana/dPoW.h
  2. 2
      iguana/dpow/dpow_network.c
  3. 104
      iguana/dpow/dpow_rpc.c
  4. 24
      iguana/dpow/dpow_tx.c
  5. 19
      iguana/iguana777.c

1
iguana/dPoW.h

@ -162,6 +162,7 @@ char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin
cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin);
void init_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);

2
iguana/dpow/dpow_network.c

@ -944,7 +944,7 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
}
}
//printf("crcval.%x numcrcs.%d bestmatches.%d matchesmask.%llx\n",crcval,numcrcs,bestmatches,(long long)matchesmask);
if ( bestmatches >= bp->minsigs )
if ( bestmatches >= bp->minsigs && numcrcs >= bp->minsigs )
{
if ( bp->pendingratifybestk != bp->ratifybestk || bp->pendingratifybestmask != bp->ratifybestmask )
{

104
iguana/dpow/dpow_rpc.c

@ -434,9 +434,72 @@ char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin)
return(retstr);
}
void update_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
{
char *alladdresses,*outstr,fname[1024],buf[512]; cJSON *alljson; int32_t i,n; FILE *fp;
if ( (alladdresses= dpow_alladdresses(myinfo,coin)) != 0 )
{
if ( (alljson= cJSON_Parse(alladdresses)) != 0 )
{
if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 )
{
for (i=0; i<n; i++)
if ( strcmp(address,jstri(alljson,i)) == 0 )
break;
if ( i == n )
{
jaddistr(alljson,address);
outstr = jprint(alljson,0);
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
fwrite(outstr,1,strlen(outstr)+1,fp);
fclose(fp);
printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol);
}
free(outstr);
}
}
free_json(alljson);
}
free(alladdresses);
}
else
{
sprintf(buf,"[\"%s\"]",address);
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
printf("%s first importaddress.(%s) -> %s\n",coin->symbol,address,fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
fwrite(buf,1,strlen(buf)+1,fp);
fclose(fp);
}
}
}
void init_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin)
{
char *alladdresses,*retstr; cJSON *alljson; int32_t i,n;
if ( (alladdresses= _dex_alladdresses(myinfo,coin->symbol)) != 0 )
{
printf("(%s) ALL.(%s)\n",coin->symbol,alladdresses);
if ( (alljson= cJSON_Parse(alladdresses)) != 0 )
{
if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 )
{
for (i=0; i<n; i++)
if ( (retstr= dpow_importaddress(myinfo,coin,jstri(alljson,i))) != 0 )
free(retstr);
}
free_json(alljson);
}
free(alladdresses);
}
}
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
{
char buf[1024],*retstr,*alladdresses,*outstr,fname[1024]; cJSON *alljson,*validatejson; int32_t i,n,doneflag = 0; FILE *fp;
char buf[1024],*retstr; cJSON *validatejson; int32_t doneflag = 0;
if ( (retstr= dpow_validateaddress(myinfo,coin,address)) != 0 )
{
if ( (validatejson= cJSON_Parse(retstr)) != 0 )
@ -455,44 +518,7 @@ char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,c
sprintf(buf,"[\"%s\", \"%s\", false]",address,address);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"importaddress",buf);
printf("%s importaddress.(%s) -> (%s)\n",coin->symbol,address,retstr);
if ( (alladdresses= dpow_alladdresses(myinfo,coin)) != 0 )
{
if ( (alljson= cJSON_Parse(alladdresses)) != 0 )
{
if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 )
{
for (i=0; i<n; i++)
if ( strcmp(address,jstri(alljson,i)) == 0 )
break;
if ( i == n )
{
jaddistr(alljson,address);
outstr = jprint(alljson,0);
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
fwrite(outstr,1,strlen(outstr)+1,fp);
fclose(fp);
printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol);
}
free(outstr);
}
}
free_json(alljson);
}
free(alladdresses);
}
else
{
sprintf(buf,"[\"%s\"]",address);
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
printf("%s first importaddress.(%s) -> %s\n",coin->symbol,address,fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{
fwrite(buf,1,strlen(buf)+1,fp);
fclose(fp);
}
}
update_alladdresses(myinfo,coin,address);
return(retstr);
}
else return(0);

24
iguana/dpow/dpow_tx.c

@ -256,7 +256,7 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in
bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t usesigs,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified)
{
uint32_t k,m,numsigs,version,vout,sequenceid = 0xffffffff; bits256 zero; int32_t n,siglen,len; uint8_t serialized[32768],*sig; bits256 txid; struct dpow_entry *ep; struct dpow_coinentry *cp;
uint32_t k,m,numsigs,version,vout,crcval,sequenceid = 0xffffffff; bits256 zero; int32_t n,siglen,len; uint8_t serialized[32768],*sig; bits256 txid; struct dpow_entry *ep; struct dpow_coinentry *cp;
signedtx[0] = 0;
*numsigsp = 0;
memset(zero.bytes,0,sizeof(zero));
@ -336,6 +336,16 @@ bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow
len += n;
init_hexbytes_noT(signedtx,serialized,len);
//printf("notarytx.(%s) opretlen.%d\n",signedtx,opretlen);
if ( usesigs == 0 && bestk >= 0 )
{
crcval = calc_crc32(0,bp->ratifyrawtx[src_or_dest],bp->rawratifiedlens[src_or_dest]);
if ( crcval != bp->pendingcrcs[src_or_dest] )
{
printf("new crcval.[%d] %x != %x\n",src_or_dest,crcval,bp->pendingcrcs[src_or_dest]);
bp->pendingcrcs[src_or_dest] = crcval;
}
bp->notaries[bp->myind].pendingcrcs[src_or_dest] = bp->pendingcrcs[src_or_dest];
}
*numsigsp = numsigs;
return(bits256_doublesha256(0,serialized,len));
}
@ -486,7 +496,7 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct dpow_info *dp,struct igu
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,uint32_t deprec,int32_t src_or_dest,int32_t useratified)
{
int32_t j,m,numsigs,len,siglen,retval=-1; uint32_t crcval; char rawtx[32768],*jsonstr,*rawtx2,*signedtx,*sigstr; cJSON *item,*sobj,*vins,*vin,*txobj2,*signobj; bits256 txid,srchash,zero; struct dpow_entry *ep;
int32_t j,m,numsigs,len,siglen,retval=-1; char rawtx[32768],*jsonstr,*rawtx2,*signedtx,*sigstr; cJSON *item,*sobj,*vins,*vin,*txobj2,*signobj; bits256 txid,srchash,zero; struct dpow_entry *ep;
ep = &bp->notaries[myind];
memset(&zero,0,sizeof(zero));
if ( bestk < 0 )
@ -504,14 +514,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc
len = (int32_t)strlen(rawtx) >> 1;
if ( len <= sizeof(bp->ratifyrawtx[0]) )
{
decode_hex(bp->ratifyrawtx[src_or_dest],len,rawtx), bp->rawratifiedlens[src_or_dest] = len;
crcval = calc_crc32(0,bp->ratifyrawtx[src_or_dest],bp->rawratifiedlens[src_or_dest]);
if ( crcval != bp->pendingcrcs[src_or_dest] )
{
printf("new crcval.[%d] %x != %x\n",src_or_dest,crcval,bp->pendingcrcs[src_or_dest]);
bp->pendingcrcs[src_or_dest] = crcval;
}
bp->notaries[bp->myind].pendingcrcs[src_or_dest] = bp->pendingcrcs[src_or_dest];
decode_hex(bp->ratifyrawtx[src_or_dest],len,rawtx),bp->rawratifiedlens[src_or_dest] = len;
}
if ( (jsonstr= dpow_signrawtransaction(myinfo,coin,rawtx,vins)) != 0 )
{
@ -564,6 +567,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL;
if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 )
{
dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,pubkeys,numratified); // setcrcval
signedtxid = dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified);
//printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx);
bp->state = 1;

19
iguana/iguana777.c

@ -879,7 +879,7 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin)
void iguana_coinloop(void *arg)
{
struct supernet_info *myinfo; int32_t flag,i,j,n; cJSON *alljson; struct iguana_peer *addr; bits256 zero; uint32_t now; char *alladdresses,*retstr; struct iguana_info *coin,**coins = arg;
struct supernet_info *myinfo; int32_t flag,i,j,n; struct iguana_peer *addr; bits256 zero; uint32_t now; struct iguana_info *coin,**coins = arg;
myinfo = SuperNET_MYINFO(0);
n = (int32_t)(long)coins[0];
coins++;
@ -896,21 +896,8 @@ void iguana_coinloop(void *arg)
if ( coin->didaddresses == 0 )
{
coin->didaddresses = 1;
if ( coin->notarychain >= 0 && myinfo->IAMNOTARY != 0 && (alladdresses= _dex_alladdresses(myinfo,coin->symbol)) != 0 )
{
printf("(%s) ALL.(%s)\n",coin->symbol,alladdresses);
if ( (alljson= cJSON_Parse(alladdresses)) != 0 )
{
if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 )
{
for (i=0; i<n; i++)
if ( (retstr= dpow_importaddress(myinfo,coin,jstri(alljson,i))) != 0 )
free(retstr);
}
free_json(alljson);
}
free(alladdresses);
}
if ( coin->notarychain >= 0 && myinfo->IAMNOTARY != 0 )
init_alladdresses(myinfo,coin);
}
if ( coin->FULLNODE < 0 || coin->notarychain >= 0 )
continue;

Loading…
Cancel
Save