diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 15fdd3609..ebbbc6b41 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -620,6 +620,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende // coin services { (void *)"VAL", &basilisk_respond_value }, { (void *)"BAL", &basilisk_respond_balances }, + { (void *)"INF", &basilisk_respond_getinfo }, }; 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 ) diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index 695ee1c83..2a65ed584 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -236,6 +236,20 @@ char *basilisk_respond_balances(struct supernet_info *myinfo,char *CMD,void *add 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_apideclares.h" diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index a5c853fd1..314b7ce91 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -421,6 +421,21 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi 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) { //static int counter; diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index f634c470c..38baf4c22 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1080,12 +1080,9 @@ double _max100(double val) else return(val); } -ZERO_ARGS(bitcoinrpc,getinfo) +cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin) { - cJSON *retjson; - if ( remoteaddr != 0 ) - return(clonestr("{\"error\":\"no remote\"}")); - retjson = cJSON_CreateObject(); + cJSON *retjson = cJSON_CreateObject(); if ( coin != 0 ) { jaddstr(retjson,"result","success"); @@ -1110,7 +1107,14 @@ ZERO_ARGS(bitcoinrpc,getinfo) jaddstr(retjson,"status",coin->statusstr); 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) diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index 4f5d1e760..f7f73d6fa 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -241,6 +241,7 @@ void SuperNET_yourip(struct supernet_info *myinfo,char *yourip); void iguana_peerkill(struct iguana_info *coin); int32_t blockhash_sha256(uint8_t *blockhashp,uint8_t *serialized,int32_t len); 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); void peggy();