Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
42044a04a8
  1. 20
      crypto777/cJSON.c
  2. 8
      iguana/SuperNET.c
  3. 10
      iguana/SuperNET.h
  4. 19
      iguana/iguana777.c
  5. 19
      iguana/iguana777.h
  6. 3
      iguana/iguana_accept.c
  7. 5
      iguana/iguana_bundles.c
  8. 12
      iguana/iguana_chains.c
  9. 2
      iguana/iguana_peers.c
  10. 6
      iguana/iguana_recv.c
  11. 272
      iguana/iguana_rpc.c
  12. 354
      iguana/iguana_wallet.c
  13. 122
      iguana/main.c
  14. 186
      iguana/ramchain_api.c
  15. 17
      includes/iguana_apideclares.h

20
crypto777/cJSON.c

@ -468,10 +468,20 @@ static char *print_object(cJSON *item,int32_t depth,int32_t fmt)
{
char **entries=0,**names=0;
char *out=0,*ptr,*ret,*str;int32_t len=7,i=0,j;
cJSON *child=item->child;
cJSON *child=item->child,*firstchild;
int32_t numentries=0,fail=0;
/* Count the number of entries. */
while (child) numentries++,child=child->next;
// Count the number of entries
firstchild = child;
while ( child )
{
numentries++;
child = child->next;
if ( child == firstchild )
{
printf("cJSON infinite loop detected\n");
break;
}
}
/* Explicitly handle empty object case */
if (!numentries)
{
@ -492,12 +502,14 @@ static char *print_object(cJSON *item,int32_t depth,int32_t fmt)
/* Collect all the results into our arrays: */
child=item->child;depth++;if (fmt) len+=depth;
while (child)
while ( child )
{
names[i]=str=print_string_ptr(child->string);
entries[i++]=ret=print_value(child,depth,fmt);
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
child=child->next;
if ( child == firstchild )
break;
}
/* Try to allocate the output string */

8
iguana/SuperNET.c

@ -646,7 +646,7 @@ int32_t SuperNET_destination(struct supernet_info *myinfo,uint32_t *destipbitsp,
return(destflag);
}
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr,uint16_t port)
{
char hexbuf[8192]; bits256 category,subhash;
int32_t hexlen,destflag,maxdelay,flag=0,newflag=0; uint32_t destipbits,timestamp; cJSON *retjson;
@ -704,7 +704,7 @@ char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
{
if ( newflag == 0 && hexmsg != 0 && SuperNET_hexmsgfind(myinfo,category,subhash,hexmsg,0) < 0 )
SuperNET_hexmsgadd(myinfo,category,subhash,hexmsg,tai_now(),remoteaddr);
if ( (retstr= SuperNET_processJSON(myinfo,json,remoteaddr)) != 0 )
if ( (retstr= SuperNET_processJSON(myinfo,json,remoteaddr,port)) != 0 )
{
//printf("retstr.(%s)\n",retstr);
if ( remoteaddr != 0 && (retjson= cJSON_Parse(retstr)) != 0 )
@ -795,7 +795,7 @@ char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *de
//return(clonestr("{\"result\":\"peer marked as dead\"}"));
return(0);
}
retstr = SuperNET_JSON(myinfo,json,ipaddr);
retstr = SuperNET_JSON(myinfo,json,ipaddr,addr->A.port);
//printf("p2pret.(%s)\n",retstr);
*delaymillisp = SuperNET_delaymillis(myinfo,maxdelay);
senderpub = jbits256(json,"mypub");
@ -1384,7 +1384,7 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase)
{
printf("decrypted.(%s)\n",decryptstr);
free(decryptstr);
if ( (passphrase= jstr(argjson,"result")) != 0 )
if ( (passphrase= jstr(argjson,"passphrase")) != 0 )
{
SuperNET_setkeys(myinfo,passphrase,(int32_t)strlen(passphrase),1);
free_json(argjson);

10
iguana/SuperNET.h

@ -75,14 +75,14 @@ struct supernet_address
struct supernet_info
{
char ipaddr[64],transport[8]; int32_t APISLEEP; int32_t iamrelay;
char ipaddr[64],transport[8]; int32_t APISLEEP; int32_t iamrelay; uint32_t expiration;
int32_t Debuglevel,readyflag,dead,POLLTIMEOUT; char rpcsymbol[16],LBpoint[64],PUBpoint[64];
//int32_t pullsock,subclient,lbclient,lbserver,servicesock,pubglobal,pubrelays,numservers;
bits256 privkey,persistent_priv,BTCmarkerhash; char secret[2048],NXTAPIURL[512];
uint8_t *recvbuf[6];
struct supernet_address myaddr;
int32_t LBsock,PUBsock,reqsock,subsock,networktimeout,maxdelay;
uint16_t LBport,PUBport,reqport,subport;
uint16_t LBport,PUBport,reqport,subport,rpcport,publicRPC;
//struct nn_pollfd pfd[SUPERNET_MAXAGENTS]; //struct relay_info active;
struct supernet_agent agents[SUPERNET_MAXAGENTS]; queue_t acceptQ;
int32_t numagents,numexchanges;
@ -151,12 +151,12 @@ struct endpoint calc_epbits(char *transport,uint32_t ipbits,uint16_t port,int32_
struct supernet_info *SuperNET_MYINFO(char *passphrase);
void SuperNET_init(void *args);
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr);
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr,uint16_t port);
char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remoteaddr);
char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remoteaddr,uint16_t port);
char *SuperNET_DHTencode(struct supernet_info *myinfo,char *destip,bits256 category,bits256 subhash,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext);
char *SuperNET_parser(struct supernet_info *myinfo,char *agent,char *method,cJSON *json,char *remoteaddr);
char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr);
char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr,uint16_t port);
char *SuperNET_DHTsend(struct supernet_info *myinfo,uint64_t destipbits,bits256 category,bits256 subhash,char *hexmsg,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext);
uint16_t SuperNET_API2num(char *agent,char *method);
int32_t SuperNET_num2API(char *agent,char *method,uint16_t num);

19
iguana/iguana777.c

@ -375,7 +375,7 @@ void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_helper(void *arg)
{
cJSON *argjson=0; int32_t retval,type,helperid=rand(),flag,allcurrent,idle=0;
cJSON *argjson=0; int32_t retval,polltimeout,type,helperid=rand(),flag,allcurrent,idle=0;
struct iguana_helper *ptr; struct iguana_info *coin; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp;
if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 )
helperid = juint(argjson,"helperid");
@ -392,6 +392,7 @@ void iguana_helper(void *arg)
//iguana_jsonQ(); cant do this here
flag = 0;
allcurrent = 1;
polltimeout = 100;
//printf("helper.%d\n",helperid);
/*if ( ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) )
{
@ -415,6 +416,8 @@ void iguana_helper(void *arg)
coin = ptr->coin;
if ( (bp= ptr->bp) != 0 && coin != 0 )
{
if ( coin->polltimeout < polltimeout )
polltimeout = coin->polltimeout;
//printf("[%d] bundleQ size.%d\n",bp->hdrsi,queue_size(&bundlesQ));
coin->numbundlesQ--;
if ( coin->started != 0 && time(NULL) >= bp->nexttime && coin->active != 0 )
@ -447,6 +450,8 @@ void iguana_helper(void *arg)
coin = ptr->coin;
if ( (bp= ptr->bp) != 0 && coin != 0 )
{
if ( coin->polltimeout < polltimeout )
polltimeout = coin->polltimeout;
//printf("call spendvectors.%d\n",bp->hdrsi);
if ( (retval= iguana_spendvectors(coin,bp)) >= 0 )
{
@ -465,11 +470,11 @@ void iguana_helper(void *arg)
printf("helper missing param? %p %p\n",coin,bp);
myfree(ptr,ptr->allocsize);
}
if ( flag == 0 )
usleep(25000);
if ( flag != 0 )
usleep(polltimeout * 250);
else if ( allcurrent != 0 )
usleep(100000);
else usleep(10000);
usleep(polltimeout * 100000);
else usleep(polltimeout * 10000);
}
}
@ -506,7 +511,7 @@ void iguana_coinloop(void *arg)
coin->idletime = 0;
if ( coin->started != 0 && coin->active != 0 )
{
if ( coin->isRT == 0 && now > coin->startutc+77 && coin->numsaved >= (coin->longestchain/coin->chain->bundlesize)*coin->chain->bundlesize && coin->blocks.hwmchain.height >= coin->longestchain-30 )
if ( coin->peers.numranked > 4 && coin->isRT == 0 && now > coin->startutc+77 && coin->numsaved >= (coin->longestchain/coin->chain->bundlesize)*coin->chain->bundlesize && coin->blocks.hwmchain.height >= coin->longestchain-30 )
{
fprintf(stderr,">>>>>>> %s isRT blockrecv.%d vs longest.%d\n",coin->symbol,coin->blocksrecv,coin->longestchain);
coin->isRT = 1;
@ -550,7 +555,7 @@ void iguana_coinloop(void *arg)
}
}
if ( flag == 0 )
usleep(10000 + coin->isRT*90000);
usleep(coin->polltimeout*1000 + coin->isRT*90000 + (coin->peers.numranked == 0)*1000000);
}
}

19
iguana/iguana777.h

@ -23,7 +23,7 @@
typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t len);
#define IGUANA_MAXSCRIPTSIZE 10001
#define IGUANA_SERIALIZE_SPENDVECTORGEN
//#define IGUANA_SERIALIZE_SPENDVECTORGEN
//#define IGUANA_SERIALIZE_BALANCEGEN
//#define IGUANA_DISABLEPEERS
#define _IGUANA_MAXSTUCKTIME 300
@ -42,8 +42,8 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t
#define IGUANA_HEADPERCENTAGE 0.
#define IGUANA_TAILPERCENTAGE 1.0
#define IGUANA_MAXPENDHDRS 1
#define IGUANA_MAXPENDINGREQUESTS 512
#define IGUANA_PENDINGREQUESTS 512
#define IGUANA_MAXPENDINGREQUESTS 3
#define IGUANA_PENDINGREQUESTS 64
#define IGUANA_MINPENDBUNDLES 2
#define IGUANA_MAXPENDBUNDLES 64
#define IGUANA_BUNDLELOOP 77
@ -190,7 +190,7 @@ struct iguana_chain
char name[32],symbol[8];
uint8_t pubtype,p2shtype,wiftype,netmagic[4];
char *genesis_hash,*genesis_hex; // hex string
uint16_t portp2p,portrpc;
uint16_t portp2p,rpcport;
uint8_t hastimestamp,unitval;
uint64_t rewards[512][2];
uint8_t genesis_hashdata[32],minconfirms;
@ -621,7 +621,7 @@ double dxblend(double *destp,double val,double decay);
// json
int32_t iguana_processjsonQ(struct iguana_info *coin); // reentrant, can be called during any idletime
char *iguana_JSON(char *);
char *iguana_JSON(char *,uint16_t port);
char *SuperNET_p2p(struct iguana_info *coin,struct iguana_peer *addr,int32_t *delaymillisp,char *ipaddr,uint8_t *data,int32_t datalen,int32_t compressed);
char *mbstr(char *str,double);
@ -744,15 +744,15 @@ int32_t btc_priv2wif(char *wifstr,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 *remoteaddr);
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr);
int32_t is_bitcoinrpc(struct supernet_info *myinfo,char *method,char *remoteaddr);
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr,uint16_t port);
cJSON *iguana_pubkeyjson(struct iguana_info *coin,char *pubkeystr);
void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit);
int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,int32_t timelimit,int32_t lag);
void ramcoder_test(void *data,int64_t len);
void iguana_exit();
int32_t iguana_pendingaccept(struct iguana_info *coin);
char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t tag,int32_t maxmillis,char *remoteaddr);
char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t tag,int32_t maxmillis,char *remoteaddr,uint16_t port);
void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t markflag);
cJSON *SuperNET_bits2json(uint8_t *serialized,int32_t datalen);
int32_t SuperNET_sendmsg(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 destpub,bits256 mypriv,bits256 mypub,uint8_t *msg,int32_t len,uint8_t *data,int32_t delaymillis);
@ -838,6 +838,9 @@ int8_t iguana_blockstatus(struct iguana_info *coin,struct iguana_block *block);
void iguana_peerslotinit(struct iguana_info *coin,struct iguana_peer *addr,int32_t slotid,uint64_t ipbits);
void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile);
int32_t iguana_reqblocks(struct iguana_info *coin);
void iguana_walletlock(struct supernet_info *myinfo);
int32_t _SuperNET_encryptjson(char *destfname,char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize,cJSON *argjson);
int32_t bitcoin_pubkeylen(const uint8_t *pubkey);
extern int32_t HDRnet,netBLOCKS;

3
iguana/iguana_accept.c

@ -72,7 +72,8 @@ void iguana_acceptloop(void *args)
printf("another daemon running, no need to have iguana accept connections\n");
return;
}
return;
if ( port != IGUANA_RPCPORT )
return;
sleep(5);
}
printf(">>>>>>>>>>>>>>>> iguana_bindloop 127.0.0.1:%d bind sock.%d\n",port,coin->bindsock);

5
iguana/iguana_bundles.c

@ -591,9 +591,10 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
int32_t counter=0;
if ( 0 && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) )
printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec);
if ( coin->enableCACHE != 0 && bp->numhashes < bp->n && (bp->speculative == 0 || bp->hdrsi >= coin->longestchain/bp->n) )
if ( bp->hdrsi == coin->bundlescount-1 || (coin->enableCACHE != 0 && bp->numhashes < bp->n && (bp->speculative == 0 || bp->hdrsi >= coin->longestchain/bp->n)) )
{
char str[64];
//printf("hdrs.%s\n",bits256_str(str,bp->hashes[0]));
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
}
if ( bp->hdrsi == coin->bundlescount-1 && bp->speculative != 0 && bits256_nonz(bp->nextbundlehash2) == 0 )
@ -752,7 +753,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
iguana_autoextend(coin,bp);
//printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->utxofinish,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount);
bp->nexttime = (uint32_t)(time(NULL) + 1);
if ( bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize )
if ( bp->hdrsi == coin->bundlescount-1 || (bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize) )
iguana_bundlehdr(coin,bp,starti);
else if ( bp->emitfinish != 0 )
{

12
iguana/iguana_chains.c

@ -286,8 +286,8 @@ void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson)
strcpy(chain->userhome,jstr(argjson,"userhome"));
else strcpy(chain->userhome,Userhome);
if ( (port= extract_userpass(chain->serverport,chain->userpass,chain->symbol,chain->userhome,path,conf)) != 0 )
chain->portrpc = port;
printf("COIN.%s serverport.(%s) userpass.(%s) port.%u\n",chain->symbol,chain->serverport,chain->userpass,chain->portrpc);
chain->rpcport = port;
printf("COIN.%s serverport.(%s) userpass.(%s) port.%u\n",chain->symbol,chain->serverport,chain->userpass,chain->rpcport);
if ( (hexstr= jstr(argjson,"pubval")) != 0 && strlen(hexstr) == 2 )
decode_hex((uint8_t *)&chain->pubtype,1,hexstr);
if ( (hexstr= jstr(argjson,"scriptval")) != 0 && strlen(hexstr) == 2 )
@ -332,8 +332,8 @@ void iguana_chainparms(struct iguana_chain *chain,cJSON *argjson)
chain->portp2p = juint(argjson,"p2p");
if ( (chain->ramchainport= juint(argjson,"ramchain")) == 0 )
chain->ramchainport = chain->portp2p - 1;
if ( (chain->portrpc= juint(argjson,"rpc")) == 0 )
chain->portrpc = chain->portp2p + 1;
if ( (chain->rpcport= juint(argjson,"rpc")) == 0 )
chain->rpcport = chain->portp2p + 1;
if ( (rewards= jarray(&n,argjson,"rewards")) != 0 )
{
for (i=0; i<n; i++)
@ -377,8 +377,8 @@ void iguana_chaininit(struct iguana_chain *chain,int32_t hasheaders,cJSON *argjs
decode_hex((uint8_t *)chain->genesis_hashdata,32,(char *)chain->genesis_hash);
if ( chain->ramchainport == 0 )
chain->ramchainport = chain->portp2p - 1;
if ( chain->portrpc == 0 )
chain->portrpc = chain->portp2p + 1;
if ( chain->rpcport == 0 )
chain->rpcport = chain->portp2p + 1;
}
struct iguana_chain *iguana_chainfind(char *name,cJSON *argjson,int32_t createflag)

2
iguana/iguana_peers.c

@ -333,7 +333,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port)
if ( errno == EADDRINUSE )
{
sleep(1);
printf("ERROR BINDING PORT.%d. will exit. wait up to a minute and try again. dont worry, this is normal\n",port);
printf("ERROR BINDING PORT.%d. this is normal tcp timeout, unless another process is using port\n",port);
sleep(3);
printf("%s(%s) port.%d try again: %s sock.%d. errno.%d\n",bindflag!=0?"bind":"connect",hostname,port,strerror(errno),sock,errno);
if ( bindflag == 1 )

6
iguana/iguana_recv.c

@ -1438,13 +1438,13 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
else if ( bp->numhashes < bp->n )
z = 1;
}
if ( bp == 0 || bp->speculative == 0 || bp == coin->current )
if ( bp == 0 || bp->speculative == 0 || bp == coin->current || bp->hdrsi == coin->bundlescount-1 )
{
//printf("%s request HDR.(%s) numhashes.%d\n",addr!=0?addr->ipaddr:"local",hashstr,bp!=0?bp->numhashes:0);
printf("%s request HDR.(%s) numhashes.%d\n",addr!=0?addr->ipaddr:"local",hashstr,bp!=0?bp->numhashes:0);
iguana_send(coin,addr,serialized,datalen);
addr->pendhdrs++;
flag++;
} //else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued);
} else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued);
}
free_queueitem(hashstr);
return(flag);

272
iguana/iguana_rpc.c

@ -16,17 +16,21 @@
#include "iguana777.h"
#include "SuperNET.h"
#define RPCARGS struct supernet_info *myinfo,struct iguana_info *coin,cJSON *params[],int32_t n,cJSON *json,char *remoteaddr,cJSON *array
#define RPCARGS struct supernet_info *myinfo,uint16_t port,struct iguana_info *coin,cJSON *params[],int32_t n,cJSON *json,char *remoteaddr,cJSON *array
#define GLUEARGS cJSON *json,struct supernet_info *myinfo,uint16_t port,struct iguana_info *coin,char *remoteaddr,cJSON *params[]
char *sglue(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method)
#define CALLGLUE myinfo,port,coin,remoteaddr,params
char *sglue(GLUEARGS,char *agent,char *method)
{
char *retstr,*rpcretstr; cJSON *retjson,*result,*error; int32_t i,j,len;
if ( json == 0 )
json = cJSON_CreateObject();
//printf("sglue.(%s)\n",jprint(json,0));
jaddstr(json,"agent",agent);
jaddstr(json,"method",method);
jaddstr(json,"coin",coin->symbol);
if ( (retstr= SuperNET_JSON(myinfo,json,remoteaddr)) != 0 )
if ( (retstr= SuperNET_JSON(myinfo,json,remoteaddr,port)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
@ -45,7 +49,7 @@ char *sglue(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,ch
for (i=1,j=0; i<len-1; i++,j++)
rpcretstr[j] = rpcretstr[i];
rpcretstr[j] = '\n';
free_json(json);
//free_json(json);
free_json(retjson);
free(retstr);
return(rpcretstr);
@ -58,107 +62,116 @@ char *sglue(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,ch
free_json(retjson);
}
}
free_json(json);
//free_json(json);
return(retstr);
}
char *sglue1(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method,char *field,cJSON *obj)
char *sglue1(GLUEARGS,char *agent,char *method,char *field,cJSON *obj)
{
if ( json == 0 )
json = cJSON_CreateObject();
if ( obj != 0 )
if ( obj != 0 && field != 0 )
jadd(json,field,obj);
return(sglue(json,myinfo,coin,remoteaddr,agent,method));
params[0] = 0;
//printf("sglue1.(%s)\n",jprint(json,0));
return(sglue(json,CALLGLUE,agent,method));
}
char *sglueN(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method,char *field,double num)
char *sglueN(GLUEARGS,char *agent,char *method,char *field,double num)
{
if ( json == 0 )
json = cJSON_CreateObject();
jaddnum(json,field,num);
return(sglue(json,myinfo,coin,remoteaddr,agent,method));
return(sglue(json,CALLGLUE,agent,method));
}
char *sglue2(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1)
char *sglue2(GLUEARGS,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1)
{
if ( json == 0 )
json = cJSON_CreateObject();
if ( obj1 != 0 )
if ( obj1 != 0 && field1 != 0 )
jadd(json,field1,obj1);
return(sglue1(json,myinfo,coin,remoteaddr,agent,method,field0,obj0));
params[1] = 0;
//printf("sglue2.(%s)\n",jprint(json,0));
return(sglue1(json,CALLGLUE,agent,method,field0,obj0));
}
char *sglue3(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2)
char *sglue3(GLUEARGS,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2)
{
if ( json == 0 )
json = cJSON_CreateObject();
if ( obj2 != 0 )
if ( obj2 != 0 && field2 != 0 )
jadd(json,field2,obj2);
return(sglue2(json,myinfo,coin,remoteaddr,agent,method,field0,obj0,field1,obj1));
params[2] = 0;
//printf("sglue3.(%s)\n",jprint(json,0));
return(sglue2(json,CALLGLUE,agent,method,field0,obj0,field1,obj1));
}
char *sglue4(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2,char *field3,cJSON *obj3)
char *sglue4(GLUEARGS,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2,char *field3,cJSON *obj3)
{
if ( json == 0 )
json = cJSON_CreateObject();
if ( obj3 != 0 )
if ( obj3 != 0 && field3 != 0 )
jadd(json,field3,obj3);
return(sglue3(json,myinfo,coin,remoteaddr,agent,method,field0,obj0,field1,obj1,field2,obj2));
params[3] = 0;
return(sglue3(json,CALLGLUE,agent,method,field0,obj0,field1,obj1,field2,obj2));
}
char *sglue5(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2,char *field3,cJSON *obj3,char *field4,cJSON *obj4)
char *sglue5(GLUEARGS,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2,char *field3,cJSON *obj3,char *field4,cJSON *obj4)
{
if ( json == 0 )
json = cJSON_CreateObject();
if ( obj4 != 0 )
if ( obj4 != 0 && field4 != 0 )
jadd(json,field4,obj4);
return(sglue4(json,myinfo,coin,remoteaddr,agent,method,field0,obj0,field1,obj1,field2,obj2,field3,obj3));
params[4] = 0;
return(sglue4(json,CALLGLUE,agent,method,field0,obj0,field1,obj1,field2,obj2,field3,obj3));
}
char *sglue6(cJSON *json,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2,char *field3,cJSON *obj3,char *field4,cJSON *obj4,char *field5,cJSON *obj5)
char *sglue6(GLUEARGS,char *agent,char *method,char *field0,cJSON *obj0,char *field1,cJSON *obj1,char *field2,cJSON *obj2,char *field3,cJSON *obj3,char *field4,cJSON *obj4,char *field5,cJSON *obj5)
{
if ( json == 0 )
json = cJSON_CreateObject();
if ( obj5 != 0 )
if ( obj5 != 0 && field5 != 0 )
jadd(json,field5,obj5);
return(sglue5(json,myinfo,coin,remoteaddr,agent,method,field0,obj0,field1,obj1,field2,obj2,field3,obj3,field4,obj4));
params[5] = 0;
return(sglue5(json,CALLGLUE,agent,method,field0,obj0,field1,obj1,field2,obj2,field3,obj3,field4,obj4));
}
// misc
static char *help(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"SuperNET","help"));
return(sglue(0,CALLGLUE,"SuperNET","help"));
}
static char *stop(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"iguana","pausecoin"));
return(sglue(0,CALLGLUE,"iguana","pausecoin"));
}
static char *sendalert(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"iguana","sendalert","message",params[0]));
return(sglue1(0,CALLGLUE,"iguana","sendalert","message",params[0]));
}
static char *SuperNET(RPCARGS)
{
return(SuperNET_JSON(myinfo,json,remoteaddr));
return(SuperNET_JSON(myinfo,json,remoteaddr,port));
}
static char *getrawmempool(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"iguana","getrawmempool"));
return(sglue(0,CALLGLUE,"iguana","getrawmempool"));
}
// peers
static char *getconnectioncount(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"iguana","getconnectioncount"));
return(sglue(0,CALLGLUE,"iguana","getconnectioncount"));
}
static char *getpeerinfo(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"iguana","peers"));
return(sglue(0,CALLGLUE,"iguana","peers"));
}
static char *addnode(RPCARGS)
@ -173,7 +186,7 @@ static char *addnode(RPCARGS)
else if ( strcmp(mode,"onetry") == 0 )
cmd = "onetry";
if ( cmd != 0 )
return(sglue1(0,myinfo,coin,remoteaddr,"iguana",cmd,"ipaddr",params[0]));
return(sglue1(0,CALLGLUE,"iguana",cmd,"ipaddr",params[0]));
}
// addnode <node> <add/remove/onetry> version 0.8 Attempts add or remove <node> from the addnode list or try a connection to <node> once. N
return(clonestr("{\"error\":\"invalid addnode parameter\"}"));
@ -182,201 +195,201 @@ static char *addnode(RPCARGS)
// address and pubkeys
static char *validateaddress(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","validateaddress","address",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","validateaddress","address",params[0]));
}
static char *validatepubkey(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","validatepubkey","pubkey",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","validatepubkey","pubkey",params[0]));
}
static char *createmultisig(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","createmultisig","M",params[0],"pubkeys",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","createmultisig","M",params[0],"pubkeys",params[1]));
}
static char *addmultisigaddress(RPCARGS)
{
return(sglue3(0,myinfo,coin,remoteaddr,"bitcoinrpc","createmultisig","M",params[0],"pubkeys",params[1],"account",params[2]));
return(sglue3(0,CALLGLUE,"bitcoinrpc","createmultisig","M",params[0],"pubkeys",params[1],"account",params[2]));
}
// blockchain
static char *getinfo(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","status"));
return(sglue(0,CALLGLUE,"bitcoinrpc","status"));
}
static char *getbestblockhash(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","getbestblockhash"));
return(sglue(0,CALLGLUE,"bitcoinrpc","getbestblockhash"));
}
static char *getblockcount(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","getblockcount"));
return(sglue(0,CALLGLUE,"bitcoinrpc","getblockcount"));
}
static char *getblock(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","getblock","blockhash",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","getblock","blockhash",params[0]));
}
static char *getblockhash(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","getblockhash","height",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","getblockhash","height",params[0]));
}
static char *gettransaction(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","gettransaction","txid",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","gettransaction","txid",params[0]));
}
static char *listtransactions(RPCARGS)
{
return(sglue3(0,myinfo,coin,remoteaddr,"bitcoinrpc","listtransactions","account",params[0],"count",params[1],"from",params[2]));
return(sglue3(0,CALLGLUE,"bitcoinrpc","listtransactions","account",params[0],"count",params[1],"from",params[2]));
}
static char *getreceivedbyaddress(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","getreceivedbyaddress","address",params[0],"minconfs",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","getreceivedbyaddress","address",params[0],"minconfs",params[1]));
}
static char *listreceivedbyaddress(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","listreceivedbyaddress","minconf",params[0],"includeempty",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","listreceivedbyaddress","minconf",params[0],"includeempty",params[1]));
}
static char *listsinceblock(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","listsinceblock","blockhash",params[0],"target",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","listsinceblock","blockhash",params[0],"target",params[1]));
}
// waccount and waddress funcs
static char *getreceivedbyaccount(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","getreceivedbyaccount","account",params[0],"minconfs",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","getreceivedbyaccount","account",params[0],"minconfs",params[1]));
}
static char *listreceivedbyaccount(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","listreceivedbyaccount","account",params[0],"includeempty",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","listreceivedbyaccount","account",params[0],"includeempty",params[1]));
}
static char *getnewaddress(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","getnewaddress","account",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","getnewaddress","account",params[0]));
}
static char *vanitygen(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","vanitygen","vanity",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","vanitygen","vanity",params[0]));
}
static char *makekeypair(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","makekeypair"));
return(sglue(0,CALLGLUE,"bitcoinrpc","makekeypair"));
}
static char *getaccountaddress(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","getaccountaddress","account",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","getaccountaddress","account",params[0]));
}
static char *setaccount(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","setaccount","address",params[0],"account",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","setaccount","address",params[0],"account",params[1]));
}
static char *getaccount(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","getaccount","address",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","getaccount","address",params[0]));
}
static char *getaddressesbyaccount(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","getaddressesbyaccount","account",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","getaddressesbyaccount","account",params[0]));
}
static char *listaddressgroupings(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","listaddressgroupings"));
return(sglue(0,CALLGLUE,"bitcoinrpc","listaddressgroupings"));
}
static char *getbalance(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","getbalance","account",params[0],"minconf",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","getbalance","account",params[0],"minconf",params[1]));
}
// wallet
static char *listaccounts(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","listaccounts","minconf",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","listaccounts","minconf",params[0]));
}
static char *dumpprivkey(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","dumpprivkey","address",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","dumpprivkey","address",params[0]));
}
static char *importprivkey(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","importprivkey","wif",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","importprivkey","wif",params[0]));
}
static char *dumpwallet(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","dumpwallet"));
return(sglue(0,CALLGLUE,"bitcoinrpc","dumpwallet"));
}
static char *importwallet(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","importwallet","wallet",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","importwallet","wallet",params[0]));
}
static char *walletpassphrase(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","walletpassphrase","passphrase",params[0],"timeout",params[1]));
return(sglue3(0,CALLGLUE,"bitcoinrpc","walletpassphrase","passphrase",params[0],"permanentfile",params[2],"timeout",params[1]));
}
static char *walletpassphrasechange(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","walletpassphrasechange","oldpassphrase",params[0],"newpassphrase",params[1]));
return(sglue4(0,CALLGLUE,"bitcoinrpc","walletpassphrasechange","oldpassphrase",params[0],"newpassphrase",params[1],"oldpermanentfile",params[2],"oldpermanentfile",params[3]));
}
static char *walletlock(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","walletlock"));
return(sglue(0,CALLGLUE,"bitcoinrpc","walletlock"));
}
static char *encryptwallet(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","encryptwallet","passphrase",params[0]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","encryptwallet","passphrase",params[0],"password",params[1]));
}
static char *checkwallet(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","checkwallet"));
return(sglue(0,CALLGLUE,"bitcoinrpc","checkwallet"));
}
static char *repairwallet(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","repairwallet"));
return(sglue(0,CALLGLUE,"bitcoinrpc","repairwallet"));
}
static char *backupwallet(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","backupwallet","filename",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","backupwallet","filename",params[0]));
}
// messages
static char *signmessage(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","signmessage","address",params[0],"message",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","signmessage","address",params[0],"message",params[1]));
}
static char *verifymessage(RPCARGS)
{
return(sglue3(0,myinfo,coin,remoteaddr,"bitcoinrpc","verifymessage","address",params[0],"sig",params[1],"message",params[2]));
return(sglue3(0,CALLGLUE,"bitcoinrpc","verifymessage","address",params[0],"sig",params[1],"message",params[2]));
}
// unspents
@ -399,95 +412,96 @@ static char *listunspent(RPCARGS)
if ( rmdarray != 0 )
free(rmdarray);
return(jprint(retjson,1));
// return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","listunspent","minconf",params[0],"maxconf",params[1]));
// return(sglue2(0,CALLGLUE,"bitcoinrpc","listunspent","minconf",params[0],"maxconf",params[1]));
}
static char *lockunspent(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","lockunspent","flag",params[0],"array",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","lockunspent","flag",params[0],"array",params[1]));
}
static char *listlockunspent(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","listlockunspent"));
return(sglue(0,CALLGLUE,"bitcoinrpc","listlockunspent"));
}
static char *gettxout(RPCARGS)
{
return(sglue3(0,myinfo,coin,remoteaddr,"bitcoinrpc","gettxout","txid",params[0],"vout",params[1],"mempool",params[2]));
return(sglue3(0,CALLGLUE,"bitcoinrpc","gettxout","txid",params[0],"vout",params[1],"mempool",params[2]));
}
static char *gettxoutsetinfo(RPCARGS)
{
return(sglue(0,myinfo,coin,remoteaddr,"bitcoinrpc","gettxoutsetinfo"));
return(sglue(0,CALLGLUE,"bitcoinrpc","gettxoutsetinfo"));
}
// payments
static char *sendtoaddress(RPCARGS)
{
return(sglue4(0,myinfo,coin,remoteaddr,"bitcoinrpc","sendtoaddress","address",params[0],"amount",params[1],"comment",params[2],"comment2",params[3]));
return(sglue4(0,CALLGLUE,"bitcoinrpc","sendtoaddress","address",params[0],"amount",params[1],"comment",params[2],"comment2",params[3]));
}
static char *movecmd(RPCARGS)
{
return(sglue5(0,myinfo,coin,remoteaddr,"bitcoinrpc","move","fromaccount",params[0],"toaccount",params[1],"amount",params[2],"minconf",params[3],"comment",params[4]));
return(sglue5(0,CALLGLUE,"bitcoinrpc","move","fromaccount",params[0],"toaccount",params[1],"amount",params[2],"minconf",params[3],"comment",params[4]));
}
static char *sendfrom(RPCARGS)
{
return(sglue6(0,myinfo,coin,remoteaddr,"bitcoinrpc","sendfrom","fromaccount",params[0],"toaddress",params[1],"amount",params[2],"minconf",params[3],"comment",params[4],"comment2",params[5]));
return(sglue6(0,CALLGLUE,"bitcoinrpc","sendfrom","fromaccount",params[0],"toaddress",params[1],"amount",params[2],"minconf",params[3],"comment",params[4],"comment2",params[5]));
}
static char *sendmany(RPCARGS)
{
return(sglue4(0,myinfo,coin,remoteaddr,"bitcoinrpc","sendmany","fromaccount",params[0],"payments",params[1],"minconf",params[2],"comment",params[3]));
return(sglue4(0,CALLGLUE,"bitcoinrpc","sendmany","fromaccount",params[0],"payments",params[1],"minconf",params[2],"comment",params[3]));
}
static char *settxfee(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","settxfee","amount",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","settxfee","amount",params[0]));
}
// rawtransaction
static char *getrawtransaction(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","getrawtransaction","txid",params[0],"verbose",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","getrawtransaction","txid",params[0],"verbose",params[1]));
}
static char *createrawtransaction(RPCARGS)
{
return(sglue2(0,myinfo,coin,remoteaddr,"bitcoinrpc","createrawtransaction","vins",params[0],"vouts",params[1]));
return(sglue2(0,CALLGLUE,"bitcoinrpc","createrawtransaction","vins",params[0],"vouts",params[1]));
}
static char *decoderawtransaction(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","decoderawtransaction","rawtx",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","decoderawtransaction","rawtx",params[0]));
}
static char *decodescript(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","decodescript","script",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","decodescript","script",params[0]));
}
static char *signrawtransaction(RPCARGS)
{
return(sglue3(0,myinfo,coin,remoteaddr,"bitcoinrpc","signrawtransaction","rawtx",params[0],"vins",params[1],"privkeys",params[2]));
return(sglue3(0,CALLGLUE,"bitcoinrpc","signrawtransaction","rawtx",params[0],"vins",params[1],"privkeys",params[2]));
}
static char *sendrawtransaction(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","sendrawtransaction","rawtx",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","sendrawtransaction","rawtx",params[0]));
}
static char *getrawchangeaddress(RPCARGS)
{
return(sglue1(0,myinfo,coin,remoteaddr,"bitcoinrpc","getrawchangeaddress","account",params[0]));
return(sglue1(0,CALLGLUE,"bitcoinrpc","getrawchangeaddress","account",params[0]));
}
#define true 1
#define false 0
struct RPC_info { char *name; char *(*rpcfunc)(RPCARGS); int32_t flag0,remoteflag; } RPCcalls[] =
{
{ "walletpassphrase", &walletpassphrase, true, false },
{ "SuperNET", &SuperNET, false, true },
//{ "SuperNETb", &SuperNET, false, true },
{ "help", &help, true, false },
@ -509,7 +523,6 @@ struct RPC_info { char *name; char *(*rpcfunc)(RPCARGS); int32_t flag0,remotefla
{ "listreceivedbyaddress", &listreceivedbyaddress, false, false },
{ "listreceivedbyaccount", &listreceivedbyaccount, false, false },
{ "backupwallet", &backupwallet, true, false },
{ "walletpassphrase", &walletpassphrase, true, false },
{ "walletpassphrasechange", &walletpassphrasechange, false, false },
{ "walletlock", &walletlock, true, false },
{ "encryptwallet", &encryptwallet, false, false },
@ -577,55 +590,83 @@ struct RPC_info { char *name; char *(*rpcfunc)(RPCARGS); int32_t flag0,remotefla
// { "reservebalance", &reservebalance, false, true},
};
int32_t is_bitcoinrpc(char *method,char *remoteaddr)
int32_t is_bitcoinrpc(struct supernet_info *myinfo,char *method,char *remoteaddr)
{
int32_t i;
for (i=0; i<sizeof(RPCcalls)/sizeof(*RPCcalls); i++)
{
if ( strcmp(RPCcalls[i].name,method) == 0 )
{
if ( RPCcalls[i].remoteflag != 0 || (RPCcalls[i].remoteflag == 0 && (remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0)) )
if ( remoteaddr == 0 || remoteaddr[0] == 0 || strcmp(remoteaddr,"127.0.0.1") == 0 )
return(1);
if ( RPCcalls[i].remoteflag != 0 && myinfo->publicRPC != 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,cJSON *array)
char *iguana_bitcoinrpc(struct supernet_info *myinfo,uint16_t port,struct iguana_info *coin,char *method,cJSON *params[16],int32_t n,cJSON *json,char *remoteaddr,cJSON *array)
{
int32_t i;
for (i=0; i<sizeof(RPCcalls)/sizeof(*RPCcalls); i++)
{
if ( strcmp(RPCcalls[i].name,method) == 0 )
return((*RPCcalls[i].rpcfunc)(myinfo,coin,params,n,json,remoteaddr,array));
return((*RPCcalls[i].rpcfunc)(myinfo,port,coin,params,n,json,remoteaddr,array));
}
return(clonestr("{\"error\":\"invalid coin address\"}"));
}
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr)
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr,uint16_t port)
{
cJSON *params[16],*array; struct iguana_info *coin; char *symbol; int32_t i,n; char *retstr = 0;
cJSON *params[16],*array; struct iguana_info *coin = 0; char *symbol; int32_t i,c,n; char *retstr = 0;
memset(params,0,sizeof(params));
if ( json != 0 )
{
if ( (symbol= jstr(json,"coin")) == 0 || symbol[0] == 0 )
symbol = myinfo->rpcsymbol;
if ( method != 0 && symbol != 0 && (coin= iguana_coinfind(symbol)) != 0 )
if ( port == myinfo->rpcport )
{
if ( (symbol= jstr(json,"coin")) == 0 || symbol[0] == 0 )
{
symbol = myinfo->rpcsymbol;
if ( symbol[0] == 0 )
{
c = 'B';
sprintf(symbol,"%c%c%c%c",c,'T',c+1,c+2);
}
}
}
else
{
for (i=0; i<IGUANA_MAXCOINS; i++)
if ( (coin= Coins[i]) != 0 && coin->chain->rpcport == port )
break;
if ( i == IGUANA_MAXCOINS )
coin = 0;
}
//printf("method.(%s) (%s) remote.%s symbol.(%s)\n",method,jprint(json,0),remoteaddr,symbol);
if ( method != 0 && symbol != 0 && (coin != 0 || (coin= iguana_coinfind(symbol)) != 0) )
{
if ( (array= jarray(&n,json,"params")) == 0 )
{
n = 1;
params[0] = jobj(json,"params");
i= 0, n = 1;
if ( jobj(json,"params") != 0 )
params[0] = cJSON_DetachItemFromArray(array,0);//;
//printf("add params[%d] of %d <- (%s) %p\n",i,n,jprint(params[0],0),params[0]);
}
else
else if ( n > 0 )
{
params[0] = jitem(array,0);
if ( n > 1 )
for (i=1; i<n; i++)
params[i] = jitem(array,i);
for (i=n-1; i>=0; i--)
{
params[i] = cJSON_DetachItemFromArray(array,i);//;
//printf("add params[%d] of %d <- (%s) %p.(%p %p)\n",i,n,jprint(params[i],0),params[i],params[i]->next,params[i]->prev);
}
}
retstr = iguana_bitcoinrpc(myinfo,coin,method,params,n,json,remoteaddr,array);
} else free_json(json);
retstr = iguana_bitcoinrpc(myinfo,port,coin,method,params,n,json,remoteaddr,array);
if ( n > 0 )
for (i=0; i<n; i++)
if ( params[i] != 0 )
free_json(params[i]);
}
}
if ( retstr == 0 )
retstr = clonestr("{\"error\":\"cant parse jsonstr\"}");
@ -718,7 +759,7 @@ cJSON *SuperNET_urlconv(char *value,int32_t bufsize,char *urlstr)
return(json);
}
char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *postflagp,char *urlstr,char *remoteaddr,char *filetype)
char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *postflagp,char *urlstr,char *remoteaddr,char *filetype,uint16_t port)
{
cJSON *tokens,*argjson,*json = 0; long filesize;
char symbol[16],buf[4096],urlmethod[16],*data,url[1024],*retstr,*filestr,*token = 0; int32_t i,j,n,num=0;
@ -912,7 +953,7 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
free_json(argjson);
return(0);
}
retstr = SuperNET_JSON(myinfo,argjson,remoteaddr);
retstr = SuperNET_JSON(myinfo,argjson,remoteaddr,port);
//printf("(%s) {%s} -> (%s) postflag.%d (%s)\n",urlstr,jprint(argjson,0),cJSON_Print(json),*postflagp,retstr);
free_json(argjson);
return(retstr);
@ -949,12 +990,15 @@ void iguana_rpcloop(void *args)
int32_t recvlen,flag,bindsock,postflag,contentlen,sock,remains,numsent,jsonflag,hdrsize,len;
socklen_t clilen; char remoteaddr[64],*buf,*retstr,*space;//,*retbuf; ,n,i,m
struct sockaddr_in cli_addr; uint32_t ipbits,i,size = IGUANA_WIDTH*IGUANA_HEIGHT*16 + 512;
port = IGUANA_RPCPORT;
port = myinfo->rpcport;
if ( jsonbuf == 0 )
jsonbuf = calloc(1,IGUANA_MAXPACKETSIZE);
while ( (bindsock= iguana_socket(1,"127.0.0.1",port)) < 0 )
exit(-1);
printf("iguana_rpcloop 127.0.0.1:%d bind sock.%d\n",port,bindsock);
{
//exit(-1);
sleep(3);
}
printf(">>>>>>>>>> iguana_rpcloop 127.0.0.1:%d bind sock.%d iguana API enabled <<<<<<<<<\n",port,bindsock);
space = calloc(1,size);
while ( bindsock >= 0 )
{
@ -1029,7 +1073,7 @@ void iguana_rpcloop(void *args)
content_type[0] = 0;
if ( recvlen > 0 )
{
retstr = SuperNET_rpcparse(myinfo,space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype);
retstr = SuperNET_rpcparse(myinfo,space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype,port);
if ( filetype[0] != 0 )
{
static cJSON *mimejson; char *tmp,*typestr=0; long tmpsize;

354
iguana/iguana_wallet.c

@ -15,6 +15,26 @@
#include "iguana777.h"
void iguana_walletlock(struct supernet_info *myinfo)
{
memset(&myinfo->persistent_priv,0,sizeof(myinfo->persistent_priv));
memset(myinfo->secret,0,sizeof(myinfo->secret));
printf("wallet locked\n");
}
int32_t iguana_ismine(struct supernet_info *myinfo,uint8_t pubkey[65],uint8_t rmd160[20])
{
/*int32_t i;
for (i=0; i<myinfo->numaddrs; i++)
{
if ( memcmp(myinfo->addrs[i].rmd160,rmd160,sizeof(myinfo->addrs[i].rmd160)) == 0 )
{
memcpy(pubkey,myinfo->addrs[i].pubkey,bitcoin_pubkeylen(myinfo->addrs[i].pubkey));
return(i);
}
}*/
return(0);
}
uint8_t *iguana_rmdarray(struct iguana_info *coin,int32_t *numrmdsp,cJSON *array,int32_t firsti)
{
@ -120,9 +140,13 @@ struct iguana_waccount *iguana_waddressfind(struct iguana_info *coin,int32_t *in
return(0);
}
int32_t iguana_addressvalidate(struct iguana_info *coin,char *coinaddr)
int32_t iguana_addressvalidate(struct iguana_info *coin,uint8_t *addrtypep,uint8_t rmd160[20],char *address)
{
return(0);
char checkaddr[64];
bitcoin_addr2rmd160(addrtypep,rmd160,address);
if ( bitcoin_address(checkaddr,*addrtypep,rmd160,20) == checkaddr && strcmp(address,checkaddr) == 0 && (*addrtypep == coin->chain->pubtype || *addrtypep == coin->chain->p2shtype) )
return(0);
else return(-1);
}
char *getnewaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *account)
@ -171,10 +195,10 @@ char *getaccountaddress(struct supernet_info *myinfo,struct iguana_info *coin,ch
char *setaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *account,char *coinaddr)
{
struct iguana_waccount *wacct; struct iguana_waddress *waddr=0,addr; int32_t ind=-1;
struct iguana_waccount *wacct; uint8_t addrtype,rmd160[20]; struct iguana_waddress *waddr=0,addr; int32_t ind=-1;
if ( coinaddr != 0 && coinaddr[0] != 0 && account != 0 && account[0] != 0 )
{
if ( iguana_addressvalidate(coin,coinaddr) < 0 )
if ( iguana_addressvalidate(coin,&addrtype,rmd160,coinaddr) < 0 )
return(clonestr("{\"error\":\"invalid coin address\"}"));
if ( (wacct= iguana_waddressfind(coin,&ind,coinaddr)) == 0 )
{
@ -189,8 +213,8 @@ char *setaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *acc
char *getaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr)
{
struct iguana_waccount *wacct; cJSON *retjson; int32_t ind;
if ( iguana_addressvalidate(coin,coinaddr) < 0 )
struct iguana_waccount *wacct; uint8_t addrtype,rmd160[20]; cJSON *retjson; int32_t ind;
if ( iguana_addressvalidate(coin,&addrtype,rmd160,coinaddr) < 0 )
return(clonestr("{\"error\":\"invalid coin address\"}"));
if ( (wacct= iguana_waddressfind(coin,&ind,coinaddr)) == 0 )
return(clonestr("{\"result\":\"no account for address\"}"));
@ -217,11 +241,11 @@ char *getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_info *coi
char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,double amount,char *comment,char *comment2)
{
//char *coinaddr;
uint8_t addrtype,rmd160[20];
//sendtoaddress <bitcoinaddress> <amount> [comment] [comment-to] <amount> is a real and is rounded to 8 decimal places. Returns the transaction ID <txid> if successful. Y
if ( coinaddr != 0 && coinaddr[0] != 0 && amount > 0. )
{
if ( iguana_addressvalidate(coin,coinaddr) < 0 )
if ( iguana_addressvalidate(coin,&addrtype,rmd160,coinaddr) < 0 )
return(clonestr("{\"error\":\"invalid coin address\"}"));
//amount = jdouble(params[1],0);
//comment = jstr(params[2],0);
@ -230,3 +254,317 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
}
return(clonestr("{\"error\":\"need address and amount\"}"));
}
char *jsuccess()
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
#include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h"
INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,array,account)
{
cJSON *retjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
char *iguana_addressconv(struct iguana_info *coin,char *destaddr,struct iguana_info *other,int32_t isp2sh,uint8_t rmd160[20])
{
if ( bitcoin_address(destaddr,isp2sh != 0 ? other->chain->pubtype : other->chain->p2shtype,rmd160,20) == destaddr )
return(destaddr);
else return(0);
}
STRING_ARG(bitcoinrpc,validateaddress,address)
{
cJSON *retjson; int32_t i; uint8_t addrtype,rmd160[20],pubkey[65]; struct iguana_info *other; char checkaddr[64],str[256];
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( iguana_addressvalidate(coin,&addrtype,rmd160,address) < 0 )
return(clonestr("{\"error\":\"invalid coin address\"}"));
if ( strcmp(address,checkaddr) == 0 )
{
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddnum(retjson,"addrtype",addrtype);
init_hexbytes_noT(str,rmd160,sizeof(rmd160));
jaddstr(retjson,"rmd160",str);
if ( iguana_ismine(myinfo,pubkey,rmd160) > 0 )
{
init_hexbytes_noT(str,pubkey,bitcoin_pubkeylen(pubkey));
jaddstr(retjson,"pubkey",str);
cJSON_AddTrueToObject(retjson,"ismine");
}
else cJSON_AddFalseToObject(retjson,"ismine");
for (i=0; i<IGUANA_MAXCOINS; i++)
{
if ( (other= Coins[i]) != 0 && strcmp(other->symbol,coin->symbol) != 0 )
{
iguana_addressconv(coin,str,other,addrtype == coin->chain->p2shtype,rmd160);
jaddstr(retjson,other->symbol,str);
}
}
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"couldnt regenerate address\"}"));
}
ZERO_ARGS(bitcoinrpc,getinfo)
{
cJSON *retjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
retjson = cJSON_CreateObject();
jaddstr(retjson,"result",coin->statusstr);
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,walletlock)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
iguana_walletlock(myinfo);
return(jsuccess());
}
TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout)
{
char *retstr;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( timeout <= 0 )
return(clonestr("{\"error\":\"timeout must be positive\"}"));
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,password,permanentfile,0);
myinfo->expiration = (uint32_t)time(NULL) + timeout;
return(retstr);
}
THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile)
{
char *retstr;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( password == 0 || password[0] == 0 )
password = passphrase;
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,password,permanentfile,passphrase);
iguana_walletlock(myinfo);
return(retstr);
}
FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldpermanentfile,newpermanentfile)
{
char destfname[1024],*tmpstr,*loginstr,*passphrase,*retstr = 0; cJSON *tmpjson,*payload,*loginjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( (tmpstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,oldpassword,oldpermanentfile,0)) != 0 )
{
if ( (tmpjson= cJSON_Parse(retstr)) != 0 )
{
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,0)) != 0 )
{
if ( (loginjson= cJSON_Parse(loginstr)) != 0 )
{
if ( (passphrase= jstr(loginjson,"passphrase")) != 0 )
{
if ( (payload= jobj(loginjson,"payload")) != 0 )
jadd(loginjson,"payload",payload);
_SuperNET_encryptjson(destfname,passphrase,0,newpermanentfile,0,loginjson);
iguana_walletlock(myinfo);
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,0);
}
free_json(loginjson);
}
free(loginstr);
}
free_json(tmpjson);
}
free(tmpstr);
}
if ( retstr == 0 )
retstr = clonestr("{\"error\":\"error changing walletpassphrase\"}");
return(retstr);
}
TWO_STRINGS(bitcoinrpc,setaccount,address,account)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(setaccount(myinfo,coin,account,address));
}
STRING_ARG(bitcoinrpc,getaccount,address)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(getaccount(myinfo,coin,address));
}
STRING_ARG(bitcoinrpc,getnewaddress,account)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(getnewaddress(myinfo,coin,account));
}
STRING_ARG(bitcoinrpc,getaccountaddress,account)
{
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(getaccountaddress(myinfo,coin,account));
}
TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,dumpprivkey,address)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
// multiple address
THREE_INTS(bitcoinrpc,getbalance,confirmations,includeempty,watchonly)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,getaddressesbyaccount,account)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_AND_INT(bitcoinrpc,getreceivedbyaccount,account,includeempty)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
THREE_INTS(bitcoinrpc,listreceivedbyaccount,confirmations,includeempty,watchonly)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
THREE_INTS(bitcoinrpc,listreceivedbyaddress,minconf,includeempty,flag)
{
cJSON *retjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(jsuccess());
}
STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatchonly)
{
cJSON *retjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(jsuccess());
}
S_D_SS(bitcoinrpc,sendtoaddress,address,amount,comment,comment2)
{
cJSON *retjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(jsuccess());
}
SS_D_I_SS(bitcoinrpc,sendfrom,fromaccount,toaddress,amount,minconf,comment,comment2)
{
cJSON *retjson;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
return(jsuccess());
}
DOUBLE_ARG(bitcoinrpc,settxfee,amount)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
SS_D_I_S(bitcoinrpc,move,fromaccount,toaccount,amount,minconf,comment)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
S_A_I_S(bitcoinrpc,sendmany,fromaccount,array,minconf,comment)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
// entire wallet funcs
TWO_INTS(bitcoinrpc,listaccounts,minconf,includewatchonly)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,listaddressgroupings)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,checkwallet)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,repairwallet)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,dumpwallet,filename)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,backupwallet,filename)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,importwallet,filename)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
#include "../includes/iguana_apiundefs.h"
/*
sendtoaddress
encryptwallet
sendfrom
walletlock
walletpassphrase
walletpassphrasechange
validateaddress
listreceivedbyaddress
listtransactions
not implemented yet but needed by GUI
addmultisigaddress (for generating address)
setaccount (to give labels to address)
*/

122
iguana/main.c

@ -48,7 +48,7 @@ int32_t IGUANA_NUMHELPERS = 3;
#else
int32_t IGUANA_NUMHELPERS = 3;
#endif
struct iguana_jsonitem { struct queueitem DL; struct supernet_info *myinfo; uint32_t fallback,expired,allocsize; char **retjsonstrp; char remoteaddr[64]; char jsonstr[]; };
struct iguana_jsonitem { struct queueitem DL; struct supernet_info *myinfo; uint32_t fallback,expired,allocsize; char **retjsonstrp; char remoteaddr[64]; uint16_t port; char jsonstr[]; };
uint16_t SuperNET_API2num(char *agent,char *method)
{
@ -151,12 +151,12 @@ void SuperNET_MYINFOadd(struct supernet_info *myinfo)
}
}
char *iguana_JSON(char *jsonstr)
char *iguana_JSON(char *jsonstr,uint16_t port)
{
char *retstr=0; cJSON *json;
if ( (json= cJSON_Parse(jsonstr)) != 0 )
{
retstr = SuperNET_JSON(0,json,"127.0.0.1");
retstr = SuperNET_JSON(0,json,"127.0.0.1",port);
free_json(json);
}
if ( retstr == 0 )
@ -164,20 +164,21 @@ char *iguana_JSON(char *jsonstr)
return(retstr);
}
char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remoteaddr)
char *SuperNET_jsonstr(struct supernet_info *myinfo,char *jsonstr,char *remoteaddr,uint16_t port)
{
cJSON *json; char *agent,*method;
cJSON *json; char *agent,*method,*retstr = 0;
//char str[65]; printf("SuperNET_jsonstr %p %s\n",&myinfo->privkey,bits256_str(str,myinfo->privkey));
if ( (json= cJSON_Parse(jsonstr)) != 0 )
{
method = jstr(json,"method");
if ( (agent= jstr(json,"agent")) != 0 && method != 0 )
return(SuperNET_parser(myinfo,agent,method,json,remoteaddr));
else if ( method != 0 && is_bitcoinrpc(method,remoteaddr) != 0 )
return(iguana_bitcoinRPC(myinfo,method,json,remoteaddr));
return(clonestr("{\"error\":\"need both agent and method\"}"));
}
return(clonestr("{\"error\":\"couldnt parse SuperNET_JSON\"}"));
retstr = SuperNET_parser(myinfo,agent,method,json,remoteaddr);
else if ( method != 0 && is_bitcoinrpc(myinfo,method,remoteaddr) >= 0 )
retstr = iguana_bitcoinRPC(myinfo,method,json,remoteaddr,port);
else retstr = clonestr("{\"error\":\"need both agent and method\"}");
free_json(json);
} else retstr = clonestr("{\"error\":\"couldnt parse SuperNET_JSON\"}");
return(retstr);
}
int32_t iguana_jsonQ()
@ -194,7 +195,7 @@ int32_t iguana_jsonQ()
}
if ( (ptr= queue_dequeue(&jsonQ,0)) != 0 )
{
if ( *ptr->retjsonstrp != 0 && (*ptr->retjsonstrp= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr)) == 0 )
if ( *ptr->retjsonstrp != 0 && (*ptr->retjsonstrp= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr,ptr->port)) == 0 )
*ptr->retjsonstrp = clonestr("{\"error\":\"null return from iguana_jsonstr\"}");
printf("finished.(%s) -> (%s)\n",ptr->jsonstr,*ptr->retjsonstrp!=0?*ptr->retjsonstrp:"null return");
queue_enqueue("finishedQ",&finishedQ,&ptr->DL,0);
@ -203,7 +204,7 @@ int32_t iguana_jsonQ()
return(0);
}
char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t tag,int32_t maxmillis,char *remoteaddr)
char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t tag,int32_t maxmillis,char *remoteaddr,uint16_t port)
{
struct iguana_jsonitem *ptr; char *retjsonstr = 0; int32_t len,allocsize; double expiration;
expiration = OS_milliseconds() + maxmillis;
@ -213,6 +214,7 @@ char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t
ptr = mycalloc('J',1,allocsize);
ptr->allocsize = allocsize;
ptr->myinfo = myinfo;
ptr->port = port;
ptr->retjsonstrp = &retjsonstr;
safecopy(ptr->remoteaddr,remoteaddr,sizeof(ptr->remoteaddr));
memcpy(ptr->jsonstr,jsonstr,len+1);
@ -233,7 +235,7 @@ char *iguana_blockingjsonstr(struct supernet_info *myinfo,char *jsonstr,uint64_t
return(clonestr("{\"error\":\"iguana jsonstr expired\"}"));
}
char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr)
char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr,uint16_t port)
{
cJSON *retjson; uint64_t tag; uint32_t timeout; char *jsonstr,*method,*retjsonstr,*retstr = 0;
//char str[65]; printf("processJSON %p %s\n",&myinfo->privkey,bits256_str(str,myinfo->privkey));
@ -254,8 +256,8 @@ char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remote
jsonstr = jprint(json,0);
//printf("RPC? (%s)\n",jsonstr);
if ( remoteaddr == 0 || jstr(json,"immediate") != 0 )
retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr);
else retjsonstr = iguana_blockingjsonstr(myinfo,jsonstr,tag,timeout,remoteaddr);
retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr,port);
else retjsonstr = iguana_blockingjsonstr(myinfo,jsonstr,tag,timeout,remoteaddr,port);
if ( retjsonstr != 0 )
{
if ( (retjsonstr[0] == '{' || retjsonstr[0] == '[') && (retjson= cJSON_Parse(retjsonstr)) != 0 )
@ -344,12 +346,16 @@ mksquashfs DB/BTC BTC.squash1M -b 1048576
void mainloop(struct supernet_info *myinfo)
{
int32_t i,flag; struct iguana_info *coin; struct iguana_helper *ptr; struct iguana_bundle *bp;
int32_t i,flag,isRT,numpeers; struct iguana_info *coin; struct iguana_helper *ptr; struct iguana_bundle *bp;
sleep(3);
printf("mainloop\n");
while ( 1 )
{
if ( myinfo->expiration != 0 && time(NULL) > myinfo->expiration )
iguana_walletlock(myinfo);
flag = 0;
isRT = 1;
numpeers = 0;
if ( 1 )
{
for (i=0; i<IGUANA_MAXCOINS; i++)
@ -357,6 +363,8 @@ void mainloop(struct supernet_info *myinfo)
{
if ( coin->active != 0 && coin->started != 0 )
{
isRT *= coin->isRT;
numpeers += coin->peers.numranked;
//printf("main active.%d started.%p\n",coin->active,coin->started);
//iguana_bundlestats(coin,str,IGUANA_DEFAULTLAG);
//printf("done main active.%d started.%p\n",coin->active,coin->started);
@ -415,7 +423,7 @@ void mainloop(struct supernet_info *myinfo)
iguana_jsonQ();
pangea_queues(SuperNET_MYINFO(0));
if ( flag == 0 )
usleep(10000);
usleep(1000 + isRT*100000 + (numpeers == 0)*1000000);
}
}
@ -1068,7 +1076,7 @@ int maingen(int argc, char** argv)
void iguana_main(void *arg)
{
cJSON *argjson; int32_t usessl = 0, ismainnet = 1; int32_t i; struct iguana_info *btc,*btcd;
int32_t usessl = 0, ismainnet = 1; int32_t i; struct iguana_info *btc,*btcd;
struct supernet_info *myinfo; char *tmpstr,*helperargs,*coinargs,helperstr[512];
mycalloc(0,0,0);
myinfo = SuperNET_MYINFO(0);
@ -1123,15 +1131,29 @@ void iguana_main(void *arg)
iguana_initQ(&bundlesQ,"bundlesQ");
iguana_initQ(&validateQ,"validateQ");
iguana_initQ(&balancesQ,"balancesQ");
if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 )
myinfo->rpcport = IGUANA_RPCPORT;
strcpy(myinfo->rpcsymbol,"BTCD");
if ( arg != 0 )
{
safecopy(Userhome,jstr(argjson,"userhome"),sizeof(Userhome));
if ( jstr(argjson,"tmpdir") != 0 )
cJSON *argjson;
if ( (argjson= cJSON_Parse(arg)) != 0 )
{
safecopy(GLOBALTMPDIR,jstr(argjson,"tmpdir"),sizeof(GLOBALTMPDIR));
printf("GLOBAL tmpdir.(%s)\n",GLOBALTMPDIR);
}
free_json(argjson);
if ( (myinfo->rpcport= juint(argjson,"port")) == 0 )
myinfo->rpcport = IGUANA_RPCPORT;
if ( (myinfo->publicRPC= juint(argjson,"publicRPC")) != 0 && myinfo->publicRPC != myinfo->rpcport )
myinfo->publicRPC = 0;
if ( jstr(argjson,"rpccoin") != 0 )
safecopy(myinfo->rpcsymbol,jstr(argjson,"rpccoin"),sizeof(myinfo->rpcsymbol));
safecopy(Userhome,jstr(argjson,"userhome"),sizeof(Userhome));
if ( jstr(argjson,"tmpdir") != 0 )
{
safecopy(GLOBALTMPDIR,jstr(argjson,"tmpdir"),sizeof(GLOBALTMPDIR));
printf("GLOBAL tmpdir.(%s)\n",GLOBALTMPDIR);
}
printf("call argv JSON.(%s)\n",(char *)arg);
SuperNET_JSON(myinfo,argjson,0,myinfo->rpcport);
free_json(argjson);
} else printf("error parsing.(%s)\n",(char *)arg);
}
OS_ensure_directory("help");
OS_ensure_directory("confs");
@ -1147,49 +1169,38 @@ void iguana_main(void *arg)
printf("error adding BTC.%p or BTCD.%p\n",btc,btcd);
exit(-1);
}
if ( (tmpstr= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"help\"}"),0)) != 0 )
if ( (tmpstr= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"help\"}"),0,myinfo->rpcport)) != 0 )
{
if ( (API_json= cJSON_Parse(tmpstr)) != 0 && (API_json= jobj(API_json,"result")) != 0 )
API_json = jobj(API_json,"API");
free(tmpstr);
}
printf("generated API_json\n");
if ( arg != 0 )
{
cJSON *argjson;
if ( (argjson= cJSON_Parse(arg)) != 0 )
{
printf("call argv JSON.(%s)\n",(char *)arg);
SuperNET_JSON(&MYINFO,argjson,0);
free_json(argjson);
} else printf("error parsing.(%s)\n",(char *)arg);
}
if ( IGUANA_NUMHELPERS == 0 )
IGUANA_NUMHELPERS = 1;
iguana_initQ(&TerminateQ,"TerminateQ");
category_init(&MYINFO);
if ( (coinargs= SuperNET_keysinit(&MYINFO,arg)) != 0 )
category_init(myinfo);
if ( (coinargs= SuperNET_keysinit(myinfo,arg)) != 0 )
iguana_launch(btcd,"iguana_coins",iguana_coins,coinargs,IGUANA_PERMTHREAD);
#ifdef __APPLE__
else if ( 0 )
{
sleep(1);
char *str;
//iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}"));
if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"startpend\":512,\"endpend\":128,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":512,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0)) != 0 )
//iguana_launchcoin(myinfo->rpcsymbol,cJSON_Parse("{}"));
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"startpend\":512,\"endpend\":128,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":512,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0)) != 0 )
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0)) != 0 )
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"bob\",\"password\":\"bob\",\"passphrase\":\"bob\"}"),0)) != 0 )
if ( (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"bob\",\"password\":\"bob\",\"passphrase\":\"bob\"}"),0,myinfo->rpcport)) != 0 )
free(str);
}
}
strcpy(MYINFO.rpcsymbol,"BTCD");
printf("BTC active.%d BTCD active.%d\n",iguana_coinfind("BTC")->active,iguana_coinfind("BTCD")->active);
//iguana_coinfind("BTC")->active = iguana_coinfind("BTCD")->active = 0;
}
@ -1227,24 +1238,7 @@ void iguana_main(void *arg)
printf("launch[%d] of %d (%s)\n",i,IGUANA_NUMHELPERS,helperstr);
iguana_launch(btcd,"iguana_helper",iguana_helper,helperargs,IGUANA_PERMTHREAD);
}
iguana_launch(btcd,"rpcloop",iguana_rpcloop,SuperNET_MYINFO(0),IGUANA_PERMTHREAD);
mainloop(&MYINFO);
iguana_launch(btcd,"rpcloop",iguana_rpcloop,myinfo,IGUANA_PERMTHREAD);
mainloop(myinfo);
}
/*
getinfo
sendtoaddress
encryptwallet
sendfrom
walletlock
walletpassphrase
validateaddress
walletpassphrasechange
listreceivedbyaddress
listtransactions
not implemented yet but needed by GUI
addmultisigaddress (for generating address)
setaccount (to give labels to address)
*/

186
iguana/ramchain_api.c

@ -204,13 +204,6 @@ HASH_ARG(bitcoinrpc,gettransaction,txid)
return(bitcoinrpc_getrawtransaction(IGUANA_CALLARGS,txid,1));
}
ZERO_ARGS(bitcoinrpc,getinfo)
{
cJSON *retjson = cJSON_CreateObject();
jaddstr(retjson,"result",coin->statusstr);
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,getbestblockhash)
{
cJSON *retjson = cJSON_CreateObject();
@ -225,13 +218,6 @@ ZERO_ARGS(bitcoinrpc,getblockcount)
return(jprint(retjson,1));
}
HASH_AND_TWOINTS(bitcoinrpc,listsinceblock,blockhash,target,flag)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
// pubkeys
ZERO_ARGS(bitcoinrpc,makekeypair)
{
cJSON *retjson = cJSON_CreateObject();
@ -244,7 +230,7 @@ STRING_ARG(bitcoinrpc,validatepubkey,pubkey)
return(jprint(retjson,1));
}
INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,array,account)
HASH_AND_TWOINTS(bitcoinrpc,listsinceblock,blockhash,target,flag)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
@ -338,11 +324,6 @@ STRING_AND_INT(bitcoinrpc,getreceivedbyaddress,address,minconf)
return(jprint(retjson,1));
}
THREE_INTS(bitcoinrpc,listreceivedbyaddress,minconf,includeempty,flag)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
// single address/account funcs
ZERO_ARGS(bitcoinrpc,getrawchangeaddress)
@ -351,171 +332,6 @@ ZERO_ARGS(bitcoinrpc,getrawchangeaddress)
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,getnewaddress,account)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,dumpprivkey,address)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
TWO_STRINGS(bitcoinrpc,setaccount,address,account)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,getaccount,address)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,getaccountaddress,account)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
// multiple address
THREE_INTS(bitcoinrpc,getbalance,confirmations,includeempty,watchonly)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,getaddressesbyaccount,account)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_AND_INT(bitcoinrpc,getreceivedbyaccount,account,includeempty)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
THREE_INTS(bitcoinrpc,listreceivedbyaccount,confirmations,includeempty,watchonly)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatchonly)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
// spend funcs
DOUBLE_ARG(bitcoinrpc,settxfee,amount)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
SS_D_I_S(bitcoinrpc,move,fromaccount,toaccount,amount,minconf,comment)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
SS_D_I_SS(bitcoinrpc,sendfrom,fromaccount,toaddress,amount,minconf,comment,comment2)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
S_A_I_S(bitcoinrpc,sendmany,fromaccount,array,minconf,comment)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
S_D_SS(bitcoinrpc,sendtoaddress,address,amount,comment,comment2)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
// entire wallet funcs
TWO_INTS(bitcoinrpc,listaccounts,minconf,includewatchonly)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,listaddressgroupings)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,walletlock)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,checkwallet)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
ZERO_ARGS(bitcoinrpc,repairwallet)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,dumpwallet,filename)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,backupwallet,filename)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,importwallet,filename)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_AND_INT(bitcoinrpc,walletpassphrase,passphrase,timeout)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
TWO_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassphrase,newpassphrase)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
STRING_ARG(bitcoinrpc,encryptwallet,passphrase)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
HASH_AND_STRING(bitcoinrpc,verifytx,txid,txbytes)
{
cJSON *retjson;

17
includes/iguana_apideclares.h

@ -149,9 +149,6 @@ ZERO_ARGS(bitcoinrpc,getinfo);
ZERO_ARGS(bitcoinrpc,getbestblockhash);
ZERO_ARGS(bitcoinrpc,getblockcount);
ZERO_ARGS(bitcoinrpc,listaddressgroupings);
ZERO_ARGS(bitcoinrpc,walletlock);
ZERO_ARGS(bitcoinrpc,checkwallet);
ZERO_ARGS(bitcoinrpc,repairwallet);
ZERO_ARGS(bitcoinrpc,makekeypair);
ZERO_ARGS(bitcoinrpc,gettxoutsetinfo);
ZERO_ARGS(bitcoinrpc,listlockunspent);
@ -161,9 +158,17 @@ TWO_INTS(bitcoinrpc,listaccounts,minconf,includewatchonly);
THREE_INTS(bitcoinrpc,listreceivedbyaddress,minconf,includeempty,flag);
TWOINTS_AND_ARRAY(bitcoinrpc,listunspent,minconf,maxconf,array);
ZERO_ARGS(bitcoinrpc,walletlock);
ZERO_ARGS(bitcoinrpc,checkwallet);
ZERO_ARGS(bitcoinrpc,repairwallet);
STRING_ARG(bitcoinrpc,dumpwallet,filename);
STRING_ARG(bitcoinrpc,backupwallet,filename);
STRING_ARG(bitcoinrpc,encryptwallet,passphrase);
THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile);
FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldpermanentfile,permanentfile);
STRING_ARG(bitcoinrpc,importwallet,filename);
TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout);
STRING_ARG(bitcoinrpc,validateaddress,address);
STRING_ARG(bitcoinrpc,validatepubkey,pubkey);
STRING_ARG(bitcoinrpc,getnewaddress,account);
STRING_ARG(bitcoinrpc,vanitygen,vanity);
@ -172,11 +177,10 @@ STRING_ARG(bitcoinrpc,getaddressesbyaccount,account);
STRING_ARG(bitcoinrpc,getaccount,address);
STRING_ARG(bitcoinrpc,getaccountaddress,account);
STRING_ARG(bitcoinrpc,dumpprivkey,address);
STRING_ARG(bitcoinrpc,importwallet,filename);
STRING_ARG(bitcoinrpc,decodescript,script);
TWO_STRINGS(bitcoinrpc,setaccount,address,account);
TWO_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassphrase,newpassphrase);
TWO_STRINGS(bitcoinrpc,signmessage,address,message);
THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message);
@ -185,7 +189,6 @@ THREE_INTS(bitcoinrpc,getbalance,confirmations,includeempty,watchonly);
TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan);
STRING_AND_INT(bitcoinrpc,getreceivedbyaccount,account,includeempty);
STRING_AND_INT(bitcoinrpc,walletpassphrase,passphrase,timeout);
STRING_AND_INT(bitcoinrpc,getreceivedbyaddress,address,minconf);
STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees);

Loading…
Cancel
Save