Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
e217bcb995
  1. 7
      iguana/SuperNET_keys.c
  2. 2
      iguana/iguana777.c
  3. 52
      iguana/iguana_wallet.c
  4. 2
      includes/iguana_apideclares.h

7
iguana/SuperNET_keys.c

@ -23,7 +23,6 @@
#include "../includes/cJSON.h" #include "../includes/cJSON.h"
bits256 SuperNET_wallet2shared(bits256 wallethash,bits256 wallet2priv) bits256 SuperNET_wallet2shared(bits256 wallethash,bits256 wallet2priv)
{ {
bits256 wallet2shared,seed,wallet2pub; bits256 wallet2shared,seed,wallet2pub;
@ -370,7 +369,7 @@ char *SuperNET_keysinit(struct supernet_info *myinfo,char *argjsonstr)
#include "../includes/iguana_apidefs.h" #include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h" #include "../includes/iguana_apideclares.h"
THREE_STRINGS(SuperNET,encryptjson,password,permanentfile,anything) THREE_STRINGS(SuperNET,encryptjson,password,permanentfile,payload)
{ {
char destfname[4096],pass[8192],fname2[1023]; cJSON *argjson,*retjson = cJSON_CreateObject(); char destfname[4096],pass[8192],fname2[1023]; cJSON *argjson,*retjson = cJSON_CreateObject();
safecopy(pass,password,sizeof(pass)); safecopy(pass,password,sizeof(pass));
@ -405,8 +404,8 @@ TWO_STRINGS(SuperNET,decryptjson,password,permanentfile)
//printf("decrypt.(%s %s)\n",pass,fname2); //printf("decrypt.(%s %s)\n",pass,fname2);
if ( (retjson= SuperNET_decryptedjson(pass,sizeof(pass),wallethash,fname2,sizeof(fname2),wallet2priv)) != 0 ) if ( (retjson= SuperNET_decryptedjson(pass,sizeof(pass),wallethash,fname2,sizeof(fname2),wallet2priv)) != 0 )
{ {
obj = jduplicate(jobj(retjson,"anything")); obj = jduplicate(jobj(retjson,"payload"));
jdelete(retjson,"anything"); jdelete(retjson,"payload");
jadd(retjson,"result",obj); jadd(retjson,"result",obj);
return(jprint(retjson,1)); return(jprint(retjson,1));
} }

2
iguana/iguana777.c

@ -463,7 +463,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert
} }
if ( max != coin->origbalanceswritten ) if ( max != coin->origbalanceswritten )
{ {
coin->balanceflush = max; coin->balanceflush = max+1;
while ( coin->balanceflush != 0 ) while ( coin->balanceflush != 0 )
sleep(3); sleep(3);
} else printf("skip flush when max.%d and orig.%d\n",max,coin->origbalanceswritten); } else printf("skip flush when max.%d and orig.%d\n",max,coin->origbalanceswritten);

52
iguana/iguana_wallet.c

@ -35,7 +35,7 @@ struct iguana_waddress *iguana_waddresscreate(struct iguana_info *coin,struct ig
return(waddr); return(waddr);
} }
struct iguana_waddress *iguana_waddressadd(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 *waddr)
{ {
HASH_ADD_KEYPTR(hh,wacct,waddr->coinaddr,(int32_t)strlen(waddr->coinaddr)+1,wacct); HASH_ADD_KEYPTR(hh,wacct,waddr->coinaddr,(int32_t)strlen(waddr->coinaddr)+1,wacct);
return(waddr); return(waddr);
@ -242,7 +242,7 @@ char *getnewaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
{ {
waddr = mycalloc('w',1,sizeof(*waddr)); waddr = mycalloc('w',1,sizeof(*waddr));
memcpy(waddr,&addr,sizeof(*waddr)); memcpy(waddr,&addr,sizeof(*waddr));
wacct->current = iguana_waddressadd(coin,wacct,waddr); wacct->current = iguana_waddressadd(myinfo,coin,wacct,waddr);
retjson = iguana_waddressjson(retjson,waddr); retjson = iguana_waddressjson(retjson,waddr);
jaddstr(retjson,"account",account); jaddstr(retjson,"account",account);
jaddstr(retjson,"result","success"); jaddstr(retjson,"result","success");
@ -477,7 +477,7 @@ THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile)
FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldpermanentfile,newpermanentfile) FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldpermanentfile,newpermanentfile)
{ {
char destfname[1024],*tmpstr,*loginstr,*passphrase,*retstr = 0; cJSON *tmpjson,*payload,*loginjson; char destfname[1024],*tmpstr,*loginstr,*passphrase,*retstr = 0; cJSON *tmpjson,*loginjson;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( (tmpstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,oldpassword,oldpermanentfile,0)) != 0 ) if ( (tmpstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,oldpassword,oldpermanentfile,0)) != 0 )
@ -490,8 +490,6 @@ FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldperman
{ {
if ( (passphrase= jstr(loginjson,"passphrase")) != 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); _SuperNET_encryptjson(destfname,passphrase,0,newpermanentfile,0,loginjson);
iguana_walletlock(myinfo); iguana_walletlock(myinfo);
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,0); retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,0);
@ -525,7 +523,34 @@ 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);
} }
iguana_waddresscalc(coin->chain->pubtype,coin->chain->wiftype,waddr,privkey); /*if ( myinfo->password[0] == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( bits256_nonz(waddr->privkey) == 0 )
{
iguana_waddresscalc(coin->chain->pubtype,coin->chain->wiftype,waddr,privkey);
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->password,myinfo->permanentfile,0)) != 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);
} else return(clonestr("{\"error\":\"no wallet data\"}"));
}*/
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jaddstr(retjson,"result","privkey imported"); jaddstr(retjson,"result","privkey imported");
return(jprint(retjson,1)); return(jprint(retjson,1));
@ -538,7 +563,7 @@ STRING_ARG(bitcoinrpc,dumpprivkey,address)
cJSON *retjson; struct iguana_waddress *waddr; struct iguana_waccount *wacct; cJSON *retjson; struct iguana_waddress *waddr; struct iguana_waccount *wacct;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( (waddr= iguana_waddresssearch(coin,&wacct,address)) != 0 ) if ( (waddr= iguana_waddresssearch(coin,&wacct,address)) != 0 && waddr->wifstr[0] != 0 )
{ {
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jaddstr(retjson,"result",waddr->wifstr); jaddstr(retjson,"result",waddr->wifstr);
@ -566,16 +591,21 @@ ZERO_ARGS(bitcoinrpc,repairwallet)
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
STRING_ARG(bitcoinrpc,dumpwallet,filename) STRING_ARG(bitcoinrpc,backupwallet,filename)
{ {
cJSON *retjson; cJSON *retjson;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
retjson = cJSON_CreateObject(); if ( bits256_nonz(myinfo->persistent_priv) != 0 )
return(jprint(retjson,1)); {
retjson = cJSON_CreateObject();
return(jprint(retjson,1));
} return(clonestr("{\"error\":\"wallet is locked, cant backup\"}"));
} }
STRING_ARG(bitcoinrpc,backupwallet,filename) // RZXuGgmzABFpXRmGJet8AbJoqVGEs27WgdvkSSXUMg7en8jjBW2m 2016-03-26T18:40:06Z reserve=1 # addr=GRVaqhY6XVWGeEabEEx5gE7mAQ7EYQi5JV
STRING_ARG(bitcoinrpc,dumpwallet,filename)
{ {
cJSON *retjson; cJSON *retjson;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )

2
includes/iguana_apideclares.h

@ -171,7 +171,7 @@ STRING_ARG(SuperNET,setmyipaddr,ipaddr);
FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase); FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase);
ZERO_ARGS(SuperNET,logout); ZERO_ARGS(SuperNET,logout);
ZERO_ARGS(SuperNET,activehandle); ZERO_ARGS(SuperNET,activehandle);
THREE_STRINGS(SuperNET,encryptjson,password,permanentfile,anything); THREE_STRINGS(SuperNET,encryptjson,password,permanentfile,payload);
TWO_STRINGS(SuperNET,decryptjson,password,permanentfile); TWO_STRINGS(SuperNET,decryptjson,password,permanentfile);
TWO_STRINGS(SuperNET,html,agentform,htmlfile); TWO_STRINGS(SuperNET,html,agentform,htmlfile);

Loading…
Cancel
Save