Browse Source

basilisk getinfo

release/v0.1
jl777 8 years ago
parent
commit
1703a9132c
  1. 1
      basilisk/basilisk.c
  2. 14
      basilisk/basilisk_CMD.c
  3. 15
      basilisk/basilisk_bitcoin.c
  4. 16
      iguana/iguana_wallet.c
  5. 1
      includes/iguana_funcs.h

1
basilisk/basilisk.c

@ -620,6 +620,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
// coin services // coin services
{ (void *)"VAL", &basilisk_respond_value }, { (void *)"VAL", &basilisk_respond_value },
{ (void *)"BAL", &basilisk_respond_balances }, { (void *)"BAL", &basilisk_respond_balances },
{ (void *)"INF", &basilisk_respond_getinfo },
}; };
strncpy(CMD,type,3), CMD[3] = cmd[3] = 0; strncpy(CMD,type,3), CMD[3] = cmd[3] = 0;
if ( isupper((int32_t)CMD[0]) != 0 && isupper((int32_t)CMD[1]) != 0 && isupper((int32_t)CMD[2]) != 0 ) if ( isupper((int32_t)CMD[0]) != 0 && isupper((int32_t)CMD[1]) != 0 && isupper((int32_t)CMD[2]) != 0 )

14
basilisk/basilisk_CMD.c

@ -236,6 +236,20 @@ char *basilisk_respond_balances(struct supernet_info *myinfo,char *CMD,void *add
return(retstr); return(retstr);
} }
char *basilisk_respond_getinfo(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{
char *symbol,*retstr=0; struct basilisk_item Lptr,*ptr; int32_t timeoutmillis; struct iguana_info *coin = 0;
timeoutmillis = jint(valsobj,"timeout");
if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 )
coin = iguana_coinfind(symbol);
if ( coin != 0 && (ptr= basilisk_getinfo(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 )
{
retstr = ptr->retstr;
ptr->finished = (uint32_t)time(NULL);
} else retstr = clonestr("{\"error\":\"no coin specified or error bitcoinrawtx\"}");
return(retstr);
}
#include "../includes/iguana_apidefs.h" #include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h" #include "../includes/iguana_apideclares.h"

15
basilisk/basilisk_bitcoin.c

@ -421,6 +421,21 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi
return(ptr); return(ptr);
} }
void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{
struct basilisk_item *ptr; cJSON *infojson; int32_t numsent;
if ( RELAYID >= 0 )
return(0);
if ( coin->VALIDATENODE != 0 || coin->FULLNODE != 0 )
{
infojson = iguana_getinfo(myinfo,coin);
Lptr->retstr = jprint(infojson,1);
return(Lptr);
}
ptr = basilisk_issueremote(myinfo,0,&numsent,"INF",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,0,0,0,0,BASILISK_DEFAULTDIFF);
return(ptr);
}
int32_t basilisk_voutvin_validate(struct iguana_info *coin,char *rawtx,uint64_t inputsum,uint64_t amount,uint64_t txfee) int32_t basilisk_voutvin_validate(struct iguana_info *coin,char *rawtx,uint64_t inputsum,uint64_t amount,uint64_t txfee)
{ {
//static int counter; //static int counter;

16
iguana/iguana_wallet.c

@ -1080,12 +1080,9 @@ double _max100(double val)
else return(val); else return(val);
} }
ZERO_ARGS(bitcoinrpc,getinfo) cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
{ {
cJSON *retjson; cJSON *retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
retjson = cJSON_CreateObject();
if ( coin != 0 ) if ( coin != 0 )
{ {
jaddstr(retjson,"result","success"); jaddstr(retjson,"result","success");
@ -1110,7 +1107,14 @@ ZERO_ARGS(bitcoinrpc,getinfo)
jaddstr(retjson,"status",coin->statusstr); jaddstr(retjson,"status",coin->statusstr);
jaddstr(retjson,"coin",coin->symbol); jaddstr(retjson,"coin",coin->symbol);
} }
return(jprint(retjson,1)); return(retjson);
}
ZERO_ARGS(bitcoinrpc,getinfo)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(jprint(iguana_getinfo(myinfo,coin),1));
} }
TWO_STRINGS(bitcoinrpc,setaccount,address,account) TWO_STRINGS(bitcoinrpc,setaccount,address,account)

1
includes/iguana_funcs.h

@ -241,6 +241,7 @@ void SuperNET_yourip(struct supernet_info *myinfo,char *yourip);
void iguana_peerkill(struct iguana_info *coin); void iguana_peerkill(struct iguana_info *coin);
int32_t blockhash_sha256(uint8_t *blockhashp,uint8_t *serialized,int32_t len); int32_t blockhash_sha256(uint8_t *blockhashp,uint8_t *serialized,int32_t len);
void iguana_nameset(char name[64],char *symbol,cJSON *json); void iguana_nameset(char name[64],char *symbol,cJSON *json);
cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin);
char *busdata_sync(uint32_t *noncep,char *jsonstr,char *broadcastmode,char *destNXTaddr); char *busdata_sync(uint32_t *noncep,char *jsonstr,char *broadcastmode,char *destNXTaddr);
void peggy(); void peggy();

Loading…
Cancel
Save