From 93ffa2cac5d953a251026c743a8817a87cd26291 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 15 May 2016 15:01:48 -0500 Subject: [PATCH] test --- iguana/SuperNET.c | 22 +++++++++++++++++----- iguana/SuperNET_keys.c | 2 +- iguana/iguana_wallet.c | 9 +-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/iguana/SuperNET.c b/iguana/SuperNET.c index 5cc05ff69..be552ddc1 100755 --- a/iguana/SuperNET.c +++ b/iguana/SuperNET.c @@ -1419,7 +1419,7 @@ struct supernet_info *SuperNET_accountfind(cJSON *json) FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase) { - char *argstr,*str,*decryptstr = 0; cJSON *argjson; + char *str,*decryptstr = 0; cJSON *argjson,*item,*walletitem; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); if ( handle != 0 && handle[0] != 0 ) @@ -1472,12 +1472,24 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase) jdelete(argjson,"passphrase"); if ( jobj(argjson,"error") != 0 ) jdelete(argjson,"error"); - } else argjson = cJSON_CreateObject(); + } + else + { + char rmd160str[41],str[65]; uint8_t rmd160[20],pubkey33[33]; + bitcoin_pubkey33(myinfo->ctx,pubkey33,myinfo->privkey); + calc_rmd160_sha256(rmd160,pubkey33,33); + init_hexbytes_noT(rmd160str,rmd160,20); + argjson = cJSON_CreateObject(); + item = cJSON_CreateObject(); + walletitem = cJSON_CreateObject(); + jaddstr(item,rmd160str,bits256_str(str,myinfo->privkey)); + jadd(walletitem,"default",item); + jadd(argjson,"wallet",walletitem); + myinfo->dirty = (uint32_t)time(NULL); + } jaddstr(argjson,"passphrase",passphrase); - argstr = jprint(argjson,1); - if ( (str= SuperNET_encryptjson(IGUANA_CALLARGS,password,myinfo->permanentfile,argstr)) != 0 ) + if ( (str= SuperNET_encryptjson(myinfo,coin,argjson,remoteaddr,password,myinfo->permanentfile,"")) != 0 ) free(str); - free(argstr); myinfo->expiration = (uint32_t)(time(NULL) + 3600); return(SuperNET_activehandle(IGUANA_CALLARGS)); } else return(clonestr("{\"error\":\"need passphrase\"}")); diff --git a/iguana/SuperNET_keys.c b/iguana/SuperNET_keys.c index 68d9ed82b..baa7dd345 100755 --- a/iguana/SuperNET_keys.c +++ b/iguana/SuperNET_keys.c @@ -357,7 +357,7 @@ char *SuperNET_keysinit(struct supernet_info *myinfo,char *argjsonstr) jadd64bits(json,"rand",r); //printf("call SuperNET_encryptjson\n"); _SuperNET_encryptjson(destfname,passphrase,sizeof(passphrase),fname2fa,sizeof(fname2fa),json); - //printf("save.(%s)\n",jprint(json,0)); + printf("save.(%s)\n",jprint(json,0)); free_json(json); } if ( myinfo->ipaddr[0] == 0 ) diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index 76477ce2f..3b1a9347c 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -401,7 +401,7 @@ int32_t iguana_loginsave(struct supernet_info *myinfo,struct iguana_info *coin,c if ( (passphrase= jstr(loginjson,"passphrase")) != 0 ) { _SuperNET_encryptjson(destfname,passphrase,0,myinfo->permanentfile,0,loginjson); - //printf("loginsave.(%s) <= (%s)\n",destfname,newstr); + printf("loginsave.(%s) <= (%s)\n",destfname,newstr); //iguana_walletlock(myinfo); } free_json(loginjson); @@ -788,12 +788,6 @@ void iguana_walletinitcheck(struct supernet_info *myinfo,struct iguana_info *coi } child = child->next; } - if ( strcmp(account,"default") == 0 ) - { - privkey = myinfo->privkey; - if ( iguana_waddresscalc(myinfo,coin->chain->pubtype,coin->chain->wiftype,&waddr,privkey) != 0 ) - iguana_waddressadd(myinfo,coin,wacct,&waddr,0); - } //printf("account.(%s)\n",account); } item = item->next; @@ -889,7 +883,6 @@ int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info * return(balance); } - char *getnewaddress(struct supernet_info *myinfo,struct iguana_waddress **waddrp,struct iguana_info *coin,char *account,char *retstr) { struct iguana_waddress addr; cJSON *retjson;