Browse Source

test

etomic
jl777 8 years ago
parent
commit
d90f4224ee
  1. 2
      iguana/dPoW.h
  2. 24
      iguana/dpow/dpow_network.c
  3. 15
      iguana/dpow/dpow_rpc.c
  4. 27
      iguana/iguana_notary.c
  5. 1
      includes/iguana_apideclares.h

2
iguana/dPoW.h

@ -155,6 +155,7 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c
char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
@ -164,5 +165,6 @@ char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol);
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx);
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout);
char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address);
#endif

24
iguana/dpow/dpow_network.c

@ -256,9 +256,15 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
}
else if ( dexreq.func == 'A' )
{
printf("address.(%s) datalen.%d strlen.%ld\n",(char *)&dexp->packet[datalen],datalen,strlen((char *)&dexp->packet[datalen]));
retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
*broadcastflagp = 1;
printf("address.(%s) datalen.%d strlen.%ld ->(%s)\n",(char *)&dexp->packet[datalen],datalen,strlen((char *)&dexp->packet[datalen]),retstr);
if ( retstr == 0 )
retstr = dpow_validateaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
}
else if ( dexreq.func == 'V' )
{
retstr = dpow_validateaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
}
}
if ( retstr == 0 )
@ -366,6 +372,22 @@ char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address
return(retstr);
}
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address)
{
struct dex_request dexreq; uint8_t *packet; int32_t datalen; char *retstr;
packet = calloc(1,sizeof(dexreq)+strlen(address)+1);
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'V';
datalen = dex_rwrequest(1,packet,&dexreq);
strcpy((char *)&packet[datalen],address);
printf("address.(%s) datalen.%d strlen.%ld\n",(char *)&packet[datalen],datalen,strlen(address));
datalen += strlen(address) + 1;
retstr = dex_reqsend(myinfo,"request",packet,datalen);
free(packet);
return(retstr);
}
int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32)
{
int32_t i,firstz = -1;

15
iguana/dpow/dpow_rpc.c

@ -198,9 +198,9 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2
return(json);
}
int32_t dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
{
char buf[128],*retstr=0; cJSON *ismine,*json = 0; int32_t retval = -1;
char buf[128],*retstr=0;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"\"%s\"",address);
@ -215,16 +215,7 @@ int32_t dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *co
{
return(0);
}
if ( retstr != 0 )
{
json = cJSON_Parse(retstr);
if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 )
retval = 1;
else retval = 0;
free(retstr);
}
return(retval);
return(retstr);
}
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout)

27
iguana/iguana_notary.c

@ -215,7 +215,7 @@ void dpow_addresses()
TWO_STRINGS(iguana,dpow,symbol,pubkey)
{
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*dest; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows];
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*dest; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows];
if ( myinfo->NOTARY.RELAYID < 0 )
{
if ( (retstr= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(myinfo->ipaddr),myinfo->myaddr.persistent)) != 0 )
@ -278,9 +278,25 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey)
safecopy(tmp,pubkey,sizeof(tmp));
decode_hex(dp->minerkey33,33,tmp);
bitcoin_address(srcaddr,src->chain->pubtype,dp->minerkey33,33);
srcvalid = dpow_validateaddress(myinfo,src,srcaddr);
if ( (retstr= dpow_validateaddress(myinfo,src,srcaddr)) != 0 )
{
json = cJSON_Parse(retstr);
if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 )
srcvalid = 1;
else srcvalid = 0;
free(retstr);
retstr = 0;
}
bitcoin_address(destaddr,dest->chain->pubtype,dp->minerkey33,33);
destvalid = dpow_validateaddress(myinfo,dest,destaddr);
if ( (retstr= dpow_validateaddress(myinfo,src,destaddr)) != 0 )
{
json = cJSON_Parse(retstr);
if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 )
destvalid = 1;
else destvalid = 0;
free(retstr);
retstr = 0;
}
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid);
@ -542,6 +558,11 @@ TWO_STRINGS(dex,importaddress,symbol,address)
{
return(_dex_importaddress(myinfo,symbol,address));
}
TWO_STRINGS(dex,validateaddress,symbol,address)
{
return(_dex_validateaddress(myinfo,symbol,address));
}
#include "../includes/iguana_apiundefs.h"

1
includes/iguana_apideclares.h

@ -29,6 +29,7 @@ HASH_AND_STRING(dex,getblock,hash,symbol);
TWO_STRINGS(dex,sendrawtransaction,symbol,signedtx);
HASH_AND_STRING_AND_INT(dex,gettxout,txid,symbol,vout);
TWO_STRINGS(dex,importaddress,symbol,address);
TWO_STRINGS(dex,validateaddress,symbol,address);
TWO_STRINGS(zcash,passthru,function,hex);
TWO_STRINGS(komodo,passthru,function,hex);

Loading…
Cancel
Save