Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
744f2823ce
  1. 2
      crypto777/bitcoind_RPC.c
  2. 3
      iguana/iguana777.h
  3. 2
      iguana/iguana_html.c
  4. 21
      iguana/iguana_rpc.c
  5. 9
      iguana/main.c

2
crypto777/bitcoind_RPC.c

@ -232,8 +232,6 @@ try_again:
return(0);
}
/************************************************************************
*
* Initialize the string handler so that it is thread safe

3
iguana/iguana777.h

@ -16,6 +16,7 @@
#ifndef iguana777_net_h
#define iguana777_net_h
#include "../crypto777/OS_portable.h"
#include "SuperNET.h"
//#define IGUANA_DISABLEPEERS
#define IGUANA_MAXCOINS 64
@ -679,5 +680,7 @@ int32_t btc_priv2wip(char *wipstr,uint8_t privkey[32],uint8_t addrtype);
int32_t btc_pub2rmd(uint8_t rmd160[20],uint8_t pubkey[33]);
int32_t iguana_launchcoin(char *symbol,cJSON *json);
int32_t iguana_jsonQ();
int32_t is_bitcoinrpc(char *method);
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr);
#endif

2
iguana/iguana_html.c

@ -499,7 +499,7 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
}
}
}
if ( jstr(argjson,"agent") == 0 || jstr(argjson,"method") == 0 )
if ( jstr(argjson,"method") == 0 )
{
free_json(argjson);
return(0);

21
iguana/iguana_rpc.c

@ -982,7 +982,7 @@ struct RPC_info { char *name; char *(*rpcfunc)(RPCARGS); int32_t flag0,flag1; }
{ "listaddressgroupings", &listaddressgroupings, false, false },
{ "signmessage", &signmessage, false, false },
{ "verifymessage", &verifymessage, false, false },
{ "listaccounts", &listaccounts, false, false },
{ "listaccounts", &listaccounts, false, false },
{ "settxfee", &settxfee, false, false },
{ "listsinceblock", &listsinceblock, false, false },
{ "dumpprivkey", &dumpprivkey, false, false },
@ -1032,6 +1032,17 @@ struct RPC_info { char *name; char *(*rpcfunc)(RPCARGS); int32_t flag0,flag1; }
// { "reservebalance", &reservebalance, false, true},
};
int32_t is_bitcoinrpc(char *method)
{
int32_t i;
for (i=0; i<sizeof(RPCcalls)/sizeof(*RPCcalls); i++)
{
if ( strcmp(RPCcalls[i].name,method) == 0 )
return(i);
}
return(-1);
}
char *iguana_bitcoinrpc(struct supernet_info *myinfo,struct iguana_info *coin,char *method,cJSON *params[16],int32_t n,cJSON *json,char *remoteaddr)
{
int32_t i;
@ -1043,13 +1054,13 @@ char *iguana_bitcoinrpc(struct supernet_info *myinfo,struct iguana_info *coin,ch
return(clonestr("{\"error\":\"invalid coin address\"}"));
}
char *iguana_bitcoinRPC(struct iguana_info *coin,struct supernet_info *myinfo,char *jsonstr,char *remoteaddr)
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr)
{
cJSON *json,*params[16],*array; char *method; int32_t i,n; char *retstr = 0;
cJSON *params[16],*array; struct iguana_info *coin; char *symbol; int32_t i,n; char *retstr = 0;
memset(params,0,sizeof(params));
if ( (json= cJSON_Parse(jsonstr)) != 0 )
if ( json != 0 )
{
if ( (method= jstr(json,"method")) != 0 )
if ( method != 0 && (symbol= jstr(json,"coin")) != 0 && (coin= iguana_coinfind(symbol)) != 0 )
{
if ( (array= jarray(&n,json,"params")) == 0 )
{

9
iguana/main.c

@ -97,7 +97,8 @@ char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remotead
cJSON *json; char *agent,*method;
if ( (json= cJSON_Parse(jsonstr)) != 0 )
{
if ( (agent= jstr(json,"agent")) != 0 && (method= jstr(json,"method")) != 0 )
method = jstr(json,"method");
if ( (agent= jstr(json,"agent")) != 0 && method != 0 )
{
if ( strcmp(agent,"iguana") == 0 )
return(iguana_parser(myinfo,method,json,remoteaddr));
@ -112,6 +113,8 @@ char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remotead
else if ( strcmp(agent,"hash") == 0 )
return(hash_parser(myinfo,method,json,remoteaddr));
}
else if ( method != 0 && is_bitcoinrpc(method) )
return(iguana_bitcoinRPC(myinfo,method,json,remoteaddr));
return(clonestr("{\"error\":\"need both agent and method\"}"));
}
return(clonestr("{\"error\":\"couldnt parse SuperNET_JSON\"}"));
@ -133,10 +136,10 @@ int32_t iguana_jsonQ()
}
if ( (ptr= queue_dequeue(&jsonQ,0)) != 0 )
{
printf("process.(%s)\n",ptr->jsonstr);
//printf("process.(%s)\n",ptr->jsonstr);
if ( (*ptr->retjsonstrp= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr)) == 0 )
*ptr->retjsonstrp = clonestr("{\"error\":\"null return from iguana_jsonstr\"}");
printf("finished.(%s)\n",ptr->jsonstr);
//printf("finished.(%s)\n",ptr->jsonstr);
queue_enqueue("finishedQ",&finishedQ,&ptr->DL,0);
return(1);
}

Loading…
Cancel
Save