Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
41b69c8150
  1. 4
      iguana/SuperNET.c
  2. 2
      iguana/SuperNET.h
  3. 8
      iguana/iguana_unspents.c
  4. 320
      iguana/iguana_wallet.c

4
iguana/SuperNET.c

@ -1381,7 +1381,11 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase)
if ( bits256_nonz(myinfo->persistent_priv) != 0 && (str= SuperNET_logout(IGUANA_CALLARGS)) != 0 ) if ( bits256_nonz(myinfo->persistent_priv) != 0 && (str= SuperNET_logout(IGUANA_CALLARGS)) != 0 )
free(str); free(str);
if ( handle != 0 ) if ( handle != 0 )
{
safecopy(myinfo->handle,handle,sizeof(myinfo->handle)); safecopy(myinfo->handle,handle,sizeof(myinfo->handle));
safecopy(myinfo->secret,password,sizeof(myinfo->secret));
safecopy(myinfo->permanentfile,permanentfile,sizeof(myinfo->permanentfile));
}
if ( (passphrase == 0 || passphrase[0] == 0) && (decryptstr= SuperNET_decryptjson(IGUANA_CALLARGS,password,permanentfile)) != 0 ) if ( (passphrase == 0 || passphrase[0] == 0) && (decryptstr= SuperNET_decryptjson(IGUANA_CALLARGS,password,permanentfile)) != 0 )
{ {
if ( (argjson= cJSON_Parse(decryptstr)) != 0 ) if ( (argjson= cJSON_Parse(decryptstr)) != 0 )

2
iguana/SuperNET.h

@ -78,7 +78,7 @@ struct supernet_info
char ipaddr[64],transport[8]; int32_t APISLEEP; int32_t iamrelay; uint32_t expiration; 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 Debuglevel,readyflag,dead,POLLTIMEOUT; char rpcsymbol[16],LBpoint[64],PUBpoint[64];
//int32_t pullsock,subclient,lbclient,lbserver,servicesock,pubglobal,pubrelays,numservers; //int32_t pullsock,subclient,lbclient,lbserver,servicesock,pubglobal,pubrelays,numservers;
bits256 privkey,persistent_priv,BTCmarkerhash; char secret[2048],NXTAPIURL[512]; bits256 privkey,persistent_priv,BTCmarkerhash; char secret[2048],NXTAPIURL[512],permanentfile[1024];
uint8_t *recvbuf[6]; uint8_t *recvbuf[6];
struct supernet_address myaddr; struct supernet_address myaddr;
int32_t LBsock,PUBsock,reqsock,subsock,networktimeout,maxdelay; int32_t LBsock,PUBsock,reqsock,subsock,networktimeout,maxdelay;

8
iguana/iguana_unspents.c

@ -2027,7 +2027,7 @@ int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi)
break; break;
} }
} }
else if ( hdrsi > 0 ) else if ( hdrsi > 0 && (coin->current == 0 || hdrsi != coin->current->hdrsi) )
{ {
printf("balanceflush iter.%d error loading [%d] Aptr.%p Uptr.%p numpkinds.%u numunspents.%u\n",iter,hdrsi,Aptr,Uptr,numpkinds,numunspents); printf("balanceflush iter.%d error loading [%d] Aptr.%p Uptr.%p numpkinds.%u numunspents.%u\n",iter,hdrsi,Aptr,Uptr,numpkinds,numunspents);
return(-1); return(-1);
@ -2393,7 +2393,9 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
{ {
block = coin->current->blocks[coin->current->n - 1]; block = coin->current->blocks[coin->current->n - 1];
if ( _iguana_chainlink(coin,block) <= 0 ) if ( _iguana_chainlink(coin,block) <= 0 )
printf("RT edge case couldnt link\n"); {
//printf("RT edge case couldnt link\n");
}
else printf("RT edge case\n"); else printf("RT edge case\n");
} }
if ( coin->spendvectorsaved <= 1 ) if ( coin->spendvectorsaved <= 1 )
@ -2420,7 +2422,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
iguana_RTramchainfree(coin,coin->current); iguana_RTramchainfree(coin,coin->current);
return(0); return(0);
} }
if ( coin->RTdatabad == 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi == coin->balanceswritten && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n && ((coin->RTheight <= coin->blocks.hwmchain.height && time(NULL) > bp->lastRT) || time(NULL) > bp->lastRT+10) ) if ( coin->RTdatabad == 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi >= coin->balanceswritten && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n && ((coin->RTheight <= coin->blocks.hwmchain.height && time(NULL) > bp->lastRT) || time(NULL) > bp->lastRT+10) )
{ {
if ( (block= bp->blocks[0]) == 0 || block->txvalid == 0 || block->mainchain == 0 ) if ( (block= bp->blocks[0]) == 0 || block->txvalid == 0 || block->mainchain == 0 )
{ {

320
iguana/iguana_wallet.c

@ -35,9 +35,22 @@ struct iguana_waddress *iguana_waddresscreate(struct iguana_info *coin,struct ig
return(waddr); return(waddr);
} }
struct iguana_waddress *iguana_waddressadd(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_waccount *wacct,struct iguana_waddress *waddr) struct iguana_waddress *iguana_waddressadd(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_waccount *wacct,struct iguana_waddress *refwaddr)
{ {
HASH_ADD_KEYPTR(hh,wacct,waddr->coinaddr,(int32_t)strlen(waddr->coinaddr)+1,wacct); struct iguana_waddress *waddr; int32_t len = (int32_t)strlen(refwaddr->coinaddr)+1;
HASH_FIND(hh,wacct,refwaddr->coinaddr,len,waddr);
if ( waddr == 0 )
HASH_ADD_KEYPTR(hh,wacct,waddr->coinaddr,len,wacct);
if ( waddr != refwaddr )
{
waddr->privkey = refwaddr->privkey;
memcpy(waddr->pubkey,refwaddr->pubkey,sizeof(waddr->pubkey));
memcpy(waddr->rmd160,refwaddr->rmd160,sizeof(waddr->rmd160));
strcpy(waddr->coinaddr,refwaddr->coinaddr);
strcpy(waddr->wifstr,refwaddr->wifstr);
waddr->wiftype = refwaddr->wiftype;
waddr->type = refwaddr->type;
}
return(waddr); return(waddr);
} }
@ -171,6 +184,7 @@ void iguana_walletlock(struct supernet_info *myinfo)
{ {
memset(&myinfo->persistent_priv,0,sizeof(myinfo->persistent_priv)); memset(&myinfo->persistent_priv,0,sizeof(myinfo->persistent_priv));
memset(myinfo->secret,0,sizeof(myinfo->secret)); memset(myinfo->secret,0,sizeof(myinfo->secret));
memset(myinfo->permanentfile,0,sizeof(myinfo->permanentfile));
printf("wallet locked\n"); printf("wallet locked\n");
} }
@ -230,47 +244,6 @@ cJSON *iguana_waddressjson(cJSON *item,struct iguana_waddress *waddr)
return(item); return(item);
} }
char *getnewaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *account)
{
struct iguana_waccount *wacct; struct iguana_waddress addr,*waddr; cJSON *retjson = cJSON_CreateObject();
memset(&addr,0,sizeof(addr));
if ( iguana_waddresscalc(coin->chain->pubtype,coin->chain->wiftype,&addr,rand256(1)) != 0 )
{
if ( (wacct= iguana_waccountfind(coin,account)) == 0 )
wacct = iguana_waccountcreate(coin,account);
if ( wacct != 0 )
{
waddr = mycalloc('w',1,sizeof(*waddr));
memcpy(waddr,&addr,sizeof(*waddr));
wacct->current = iguana_waddressadd(myinfo,coin,wacct,waddr);
retjson = iguana_waddressjson(retjson,waddr);
jaddstr(retjson,"account",account);
jaddstr(retjson,"result","success");
} else jaddstr(retjson,"error","cant create account");
} else jaddstr(retjson,"error","cant create address");
return(jprint(retjson,1));
}
char *getaccountaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *account)
{
struct iguana_waccount *wacct; struct iguana_waddress *waddr=0; cJSON *retjson;
if ( account != 0 && account[0] != 0 )
{
if ( (wacct= iguana_waccountfind(coin,account)) == 0 )
wacct = iguana_waccountcreate(coin,account);
if ( wacct != 0 )
{
if ( (waddr= wacct->current) == 0 )
return(getnewaddress(myinfo,coin,account));
retjson = iguana_waddressjson(0,waddr);
jaddstr(retjson,"account",account);
jaddstr(retjson,"result","success");
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"cant find account\"}"));
}
return(clonestr("{\"error\":\"no account specified\"}"));
}
char *setaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *account,char *coinaddr) char *setaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *account,char *coinaddr)
{ {
uint8_t addrtype,rmd160[20]; struct iguana_waddress *waddr=0; uint8_t addrtype,rmd160[20]; struct iguana_waddress *waddr=0;
@ -279,9 +252,8 @@ char *setaccount(struct supernet_info *myinfo,struct iguana_info *coin,char *acc
if ( iguana_addressvalidate(coin,&addrtype,rmd160,coinaddr) < 0 ) if ( iguana_addressvalidate(coin,&addrtype,rmd160,coinaddr) < 0 )
return(clonestr("{\"error\":\"invalid coin address\"}")); return(clonestr("{\"error\":\"invalid coin address\"}"));
if ( (waddr= iguana_waccountswitch(coin,account,coinaddr)) != 0 ) if ( (waddr= iguana_waccountswitch(coin,account,coinaddr)) != 0 )
{ return(clonestr("{\"result\":\"success\"}"));
else return(clonestr("{\"error\":\"couldnt set account\"}"));
} else return(clonestr("{\"error\":\"couldnt set account\"}"));
} }
return(clonestr("{\"error\":\"need address and account\"}")); return(clonestr("{\"error\":\"need address and account\"}"));
} }
@ -349,9 +321,94 @@ char *iguana_addressconv(struct iguana_info *coin,char *destaddr,struct iguana_i
else return(0); else return(0);
} }
int32_t iguana_loginsave(struct supernet_info *myinfo,struct iguana_info *coin,char *newstr)
{
cJSON *loginjson; char *passphrase,destfname[1024];
if ( (loginjson= cJSON_Parse(newstr)) != 0 )
{
if ( (passphrase= jstr(loginjson,"passphrase")) != 0 )
{
_SuperNET_encryptjson(destfname,passphrase,0,myinfo->permanentfile,0,loginjson);
iguana_walletlock(myinfo);
printf("loginsave.(%s) <= (%s)\n",destfname,newstr);
}
free_json(loginjson);
return(0);
} return(-1);
}
int32_t iguana_payloadupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *retstr,struct iguana_waddress *waddr,char *account)
{
cJSON *retjson,*accountobj,*payload,*obj; char *newstr; int32_t retval = -1;
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
payload = cJSON_DetachItemFromObject(retjson,"payload");
if ( payload == 0 )
payload = cJSON_CreateObject();
if ( (accountobj= jobj(payload,account)) != 0 && (obj= jobj(accountobj,waddr->coinaddr)) != 0 )
{
free_json(retjson);
free_json(payload);
return(0);
}
jaddbits256(payload,waddr->coinaddr,waddr->privkey);
jadd(retjson,"payload",payload);
newstr = jprint(retjson,1);
retval = iguana_loginsave(myinfo,coin,newstr);
free(newstr);
}
return(retval);
}
cJSON *iguana_walletadd(struct supernet_info *myinfo,struct iguana_info *coin,char *retstr,char *account,struct iguana_waddress *refwaddr,int32_t setcurrent)
{
cJSON *retjson=0; struct iguana_waccount *wacct; struct iguana_waddress *waddr;
if ( (wacct= iguana_waccountfind(coin,account)) == 0 )
wacct = iguana_waccountcreate(coin,account);
if ( wacct != 0 )
{
waddr = iguana_waddressfind(coin,wacct,refwaddr->coinaddr);
if ( waddr != refwaddr )
{
waddr = mycalloc('w',1,sizeof(*waddr));
memcpy(waddr,refwaddr,sizeof(*waddr));
}
iguana_waddressadd(myinfo,coin,wacct,waddr);
if ( setcurrent != 0 )
wacct->current = waddr;
if ( iguana_payloadupdate(myinfo,coin,retstr,waddr,account) < 0 )
{
retjson = cJSON_CreateObject();
jaddstr(retjson,"error","couldnt update wallet payload");
}
else
{
retjson = iguana_waddressjson(retjson,waddr);
jaddstr(retjson,"account",account);
jaddstr(retjson,"result","success");
}
}
return(retjson);
}
#include "../includes/iguana_apidefs.h" #include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h" #include "../includes/iguana_apideclares.h"
char *getnewaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *account,char *retstr)
{
struct iguana_waddress addr; cJSON *retjson;
if ( myinfo->secret[0] == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( retstr != 0 )
{
memset(&addr,0,sizeof(addr));
if ( iguana_waddresscalc(coin->chain->pubtype,coin->chain->wiftype,&addr,rand256(1)) != 0 )
retjson = iguana_walletadd(myinfo,coin,retstr,account,&addr,1);
else return(clonestr("{\"error\":\"couldnt calculate waddr\"}"));
} else return(clonestr("{\"error\":\"no wallet data\"}"));
return(jprint(retjson,1));
}
INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,array,account) INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,array,account)
{ {
cJSON *retjson; cJSON *retjson;
@ -431,16 +488,46 @@ STRING_ARG(bitcoinrpc,getaccount,address)
STRING_ARG(bitcoinrpc,getnewaddress,account) STRING_ARG(bitcoinrpc,getnewaddress,account)
{ {
char *retstr,*newretstr;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
return(getnewaddress(myinfo,coin,account)); if ( myinfo->secret[0] != 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
{
newretstr = getnewaddress(myinfo,coin,account,retstr);
free(retstr);
return(newretstr);
}
else return(clonestr("{\"error\":\"no wallet payload\"}"));
} }
STRING_ARG(bitcoinrpc,getaccountaddress,account) STRING_ARG(bitcoinrpc,getaccountaddress,account)
{ {
char *retstr; struct iguana_waccount *wacct; struct iguana_waddress *waddr=0; cJSON *retjson;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
return(getaccountaddress(myinfo,coin,account)); if ( myinfo->secret[0] != 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( account != 0 && account[0] != 0 )
{
if ( (wacct= iguana_waccountfind(coin,account)) == 0 )
wacct = iguana_waccountcreate(coin,account);
if ( wacct != 0 )
{
if ( (waddr= wacct->current) == 0 )
{
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
return(getnewaddress(myinfo,coin,account,retstr));
else return(clonestr("{\"error\":\"no wallet payload\"}"));
}
retjson = iguana_waddressjson(0,waddr);
jaddstr(retjson,"account",account);
jaddstr(retjson,"result","success");
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"cant find account\"}"));
}
return(clonestr("{\"error\":\"no account specified\"}"));
} }
ZERO_ARGS(bitcoinrpc,walletlock) ZERO_ARGS(bitcoinrpc,walletlock)
@ -509,7 +596,7 @@ FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldperman
TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan) TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan)
{ {
bits256 privkey; cJSON *retjson; struct iguana_waddress addr,*waddr; struct iguana_waccount *wacct = 0; bits256 privkey; char *retstr; cJSON *retjson; struct iguana_waddress addr,*waddr; struct iguana_waccount *wacct = 0;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
privkey = iguana_str2priv(coin,wif); privkey = iguana_str2priv(coin,wif);
@ -523,38 +610,16 @@ TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan)
if ( account != 0 && account[0] != 0 ) if ( account != 0 && account[0] != 0 )
waddr = iguana_waccountswitch(coin,account,addr.coinaddr); waddr = iguana_waccountswitch(coin,account,addr.coinaddr);
} }
/*if ( myinfo->password[0] == 0 ) if ( myinfo->secret[0] == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}")); return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
if ( bits256_nonz(waddr->privkey) == 0 )
{ {
iguana_waddresscalc(coin->chain->pubtype,coin->chain->wiftype,waddr,privkey); iguana_waddresscalc(coin->chain->pubtype,coin->chain->wiftype,waddr,privkey);
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->password,myinfo->permanentfile,0)) != 0 ) retjson = iguana_walletadd(myinfo,coin,retstr,account,waddr,0);
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
payload = cJSON_DetachItemFromObject(retjson,"payload");
if ( payload == 0 )
payload = cJSON_CreateObject();
if ( (accountobj= jobj(payload,account)) != 0 )
{
}
else
{
}
newstr = jprint(retjson,1);
iguana_waddressadd(myinfo,coin,wacct,waddr,newstr);
free(newstr);
} else return(clonestr("{\"error\":\"couldnt parse wallet data\"}"));
free(retstr); free(retstr);
} else return(clonestr("{\"error\":\"no wallet data\"}"));
}*/
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","privkey imported");
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
}
return(clonestr("{\"error\":\"cant calculate waddress\"}")); return(clonestr("{\"error\":\"cant calculate waddress\"}"));
} }
@ -591,36 +656,107 @@ ZERO_ARGS(bitcoinrpc,repairwallet)
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
STRING_ARG(bitcoinrpc,backupwallet,filename) STRING_ARG(bitcoinrpc,dumpwallet,filename)
{ {
cJSON *retjson;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( bits256_nonz(myinfo->persistent_priv) != 0 ) if ( myinfo->secret[0] != 0 )
{ return(SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0));
retjson = cJSON_CreateObject(); else return(clonestr("{\"error\":\"wallet is locked, cant backup\"}"));
return(jprint(retjson,1));
} return(clonestr("{\"error\":\"wallet is locked, cant backup\"}"));
} }
// RZXuGgmzABFpXRmGJet8AbJoqVGEs27WgdvkSSXUMg7en8jjBW2m 2016-03-26T18:40:06Z reserve=1 # addr=GRVaqhY6XVWGeEabEEx5gE7mAQ7EYQi5JV // RZXuGgmzABFpXRmGJet8AbJoqVGEs27WgdvkSSXUMg7en8jjBW2m 2016-03-26T18:40:06Z reserve=1 # addr=GRVaqhY6XVWGeEabEEx5gE7mAQ7EYQi5JV
STRING_ARG(bitcoinrpc,dumpwallet,filename) char *iguana_payloadsave(char *filename,char *payloadstr)
{ {
cJSON *retjson; FILE *fp;
if ( (fp= fopen(filename,"wb")) != 0 )
{
if ( fwrite(payloadstr,1,strlen(payloadstr),fp) != strlen(payloadstr) )
{
fclose(fp);
return(clonestr("{\"error\":\"couldnt save wallet backup\"}"));
}
fclose(fp);
return(0);
} else return(clonestr("{\"error\":\"couldnt save wallet backup\"}"));
}
STRING_ARG(bitcoinrpc,backupwallet,filename)
{
char *loginstr,*payloadstr,*retstr = 0; cJSON *retjson;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
retjson = cJSON_CreateObject(); if ( myinfo->secret[0] != 0 )
return(jprint(retjson,1)); {
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
{
if ( (retjson= cJSON_Parse(loginstr)) != 0 )
{
if ( (payloadstr= jstr(retjson,"payload")) != 0 )
retstr = iguana_payloadsave(filename,payloadstr);
free_json(retjson);
}
free(loginstr);
if ( retstr == 0 )
return(clonestr("{\"result\":\"wallet backup saved\"}"));
else return(retstr);
} else return(clonestr("{\"error\":\"no wallet payload\"}"));
} else return(clonestr("{\"error\":\"need to unlock wallet\"}"));
}
cJSON *iguana_payloadmerge(cJSON *loginjson,cJSON *importjson)
{
cJSON *retjson,*item,*obj; char *field;
if ( loginjson == 0 )
return(importjson);
else if ( importjson == 0 )
return(loginjson);
retjson = jduplicate(loginjson);
item = importjson->child;
while ( item != 0 )
{
if ( (field= jfieldname(item)) != 0 )
{
if ( (obj= jobj(retjson,field)) == 0 )
jaddbits256(retjson,field,jbits256(item,0));
}
item = item->next;
}
return(retjson);
} }
STRING_ARG(bitcoinrpc,importwallet,filename) STRING_ARG(bitcoinrpc,importwallet,filename)
{ {
cJSON *retjson; cJSON *retjson = 0,*importjson,*loginjson = 0; long filesize; char *importstr,*loginstr;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
retjson = cJSON_CreateObject(); if ( myinfo->secret[0] != 0 )
return(jprint(retjson,1)); {
if ( (importstr= OS_filestr(&filesize,filename)) != 0 )
{
if ( (importjson= cJSON_Parse(importstr)) != 0 )
{
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
{
loginjson = cJSON_Parse(loginstr);
free(loginstr);
}
retjson = iguana_payloadmerge(loginjson,importjson);
if ( importjson != 0 && importjson != retjson )
free_json(importjson);
if ( loginjson != 0 && loginjson != retjson )
free_json(loginjson);
}
else
{
free(importstr);
return(clonestr("{\"error\":\"couldnt parse import file\"}"));
}
return(clonestr("{\"result\":\"wallet imported\"}"));
} else return(clonestr("{\"error\":\"couldnt open import file\"}"));
}
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
} }
// multiple address // multiple address
@ -635,9 +771,13 @@ THREE_INTS(bitcoinrpc,getbalance,confirmations,includeempty,watchonly)
STRING_ARG(bitcoinrpc,getaddressesbyaccount,account) STRING_ARG(bitcoinrpc,getaddressesbyaccount,account)
{ {
cJSON *retjson; cJSON *retjson; struct iguana_waccount *wacct;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( (wacct= iguana_waccountfind(coin,account)) != 0 )
{
}
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
return(jprint(retjson,1)); return(jprint(retjson,1));
} }

Loading…
Cancel
Save