Browse Source

test

etomic
jl777 8 years ago
parent
commit
56292c034e
  1. 2
      iguana/dPoW.h
  2. 13
      iguana/dpow/dpow_network.c
  3. 35
      iguana/dpow/dpow_rpc.c
  4. 5
      iguana/iguana_notary.c
  5. 1
      includes/iguana_apideclares.h

2
iguana/dPoW.h

@ -158,6 +158,7 @@ char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,c
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
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);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
@ -170,5 +171,6 @@ char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *coinaddr,int32_t count,int32_t skip);
char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol);
#endif

13
iguana/dpow/dpow_network.c

@ -258,6 +258,10 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
{
retstr = dpow_sendrawtransaction(myinfo,coin,(char *)&dexp->packet[datalen]);
}
else if ( dexreq.func == '*' )
{
retstr = dpow_alladdresses(myinfo,coin);
}
else if ( dexreq.func == 'L' )
{
//printf("call list.(%s %d %d)\n",(char *)&dexp->packet[datalen],dexreq.shortarg,dexreq.intarg);
@ -333,6 +337,15 @@ char *_dex_getinfo(struct supernet_info *myinfo,char *symbol)
return(_dex_sendrequest(myinfo,&dexreq));
}
char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol)
{
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = '*';
return(_dex_sendrequest(myinfo,&dexreq));
}
char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2)
{
struct dex_request dexreq;

35
iguana/dpow/dpow_rpc.c

@ -426,13 +426,46 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
}
}
char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin)
{
char *retstr,fname[1024]; long filesize;
sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname);
retstr = OS_filestr(&filesize,fname);
return(retstr);
}
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
{
char buf[128],*retstr;
char buf[128],*retstr,*alladdresses,*outstr,fname[1024]; cJSON *alljson; int32_t i,n; FILE *fp;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"[\"%s\", \"%s\", false]",address,address);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"importaddress",buf);
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);
}
free(outstr);
}
}
free_json(alljson);
}
}
return(retstr);
}
else return(0);

5
iguana/iguana_notary.c

@ -539,6 +539,11 @@ STRING_ARG(dex,getbestblockhash,symbol)
return(_dex_getbestblockhash(myinfo,symbol));
}
STRING_ARG(dex,alladdresses,symbol)
{
return(_dex_alladdresses(myinfo,symbol));
}
STRING_AND_INT(dex,getblockhash,symbol,height)
{
return(_dex_getblockhash(myinfo,symbol,height));

1
includes/iguana_apideclares.h

@ -23,6 +23,7 @@ STRING_ARG(dpow,bindaddr,ipaddr);
TWO_STRINGS(dex,send,hex,handler);
HASH_AND_STRING(dex,gettransaction,txid,symbol);
STRING_ARG(dex,getinfo,symbol);
STRING_ARG(dex,alladdresses,symbol);
STRING_ARG(dex,getbestblockhash,symbol);
STRING_AND_INT(dex,getblockhash,symbol,height);
HASH_AND_STRING(dex,getblock,hash,symbol);

Loading…
Cancel
Save