Browse Source

test

acspeed
jl777 8 years ago
parent
commit
f98b20c6cd
  1. 30
      iguana/dpow/dpow_rpc.c
  2. 32
      iguana/iguana_notary.c

30
iguana/dpow/dpow_rpc.c

@ -141,7 +141,6 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,
return(blockhash);
}
cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash)
{
char buf[128],str[65],*retstr=0; cJSON *json = 0;
@ -169,6 +168,35 @@ 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 buf[128],*retstr=0; cJSON *ismine,*json = 0; int32_t retval = -1;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"\"%s\"",address);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"validateaddress",buf);
usleep(10000);
}
else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
{
retstr = bitcoinrpc_validateaddress(myinfo,coin,0,0,address);
}
else
{
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);
}
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout)
{
char buf[128],str[65],*retstr=0; cJSON *json = 0;

32
iguana/iguana_notary.c

@ -213,7 +213,7 @@ void dpow_addresses()
TWO_STRINGS(iguana,dpow,symbol,pubkey)
{
char *retstr; int32_t i; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows];
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*dest; 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 )
@ -246,15 +246,9 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey)
if ( strcmp(symbol,myinfo->DPOWS[i].symbol) == 0 )
return(clonestr("{\"error\":\"cant dPoW same coin again\"}"));
}
char tmp[67];
safecopy(tmp,pubkey,sizeof(tmp));
decode_hex(dp->minerkey33,33,tmp);
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s)\n",tmp);
if ( bitcoin_pubkeylen(dp->minerkey33) <= 0 )
return(clonestr("{\"error\":\"illegal pubkey\"}"));
strcpy(dp->symbol,symbol);
src = iguana_coinfind(dp->symbol);
dest = iguana_coinfind(dp->dest);
if ( strcmp(dp->symbol,"KMD") == 0 )
{
strcpy(dp->dest,"BTC");
@ -267,14 +261,30 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey)
}
if ( dp->srcconfirms > DPOW_FIFOSIZE )
dp->srcconfirms = DPOW_FIFOSIZE;
if ( src == 0 || dest == 0 )
return(clonestr("{\"error\":\"source coin or dest coin not there\"}"));
char tmp[67];
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);
bitcoin_address(destaddr,dest->chain->pubtype,dp->minerkey33,33);
destvalid = dpow_validateaddress(myinfo,dest,destaddr);
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s) %s.valid%d -> %s.valid%d\n",tmp,srcaddr,srcvalid,destaddr,destvalid);
if ( srcvalid <= 0 || destvalid <= 0 )
return(clonestr("{\"error\":\"source address or dest address has no privkey, importprivkey\"}"));
if ( bitcoin_pubkeylen(dp->minerkey33) <= 0 )
return(clonestr("{\"error\":\"illegal pubkey\"}"));
if ( dp->blocks == 0 )
{
dp->maxblocks = 100000;
dp->blocks = calloc(dp->maxblocks,sizeof(*dp->blocks));
}
myinfo->numdpows++;
if ( myinfo->numdpows++ == 0 )
portable_mutex_init(&dp->mutex);
PAX_init();
portable_mutex_init(&dp->mutex);
//printf(">>>>>>>>>>>>>>> call paxpending\n");
//uint8_t buf[32768];
//dpow_paxpending(buf);

Loading…
Cancel
Save