diff --git a/iguana/SuperNET_keys.c b/iguana/SuperNET_keys.c index 0e7b8d077..be283118e 100755 --- a/iguana/SuperNET_keys.c +++ b/iguana/SuperNET_keys.c @@ -309,7 +309,7 @@ int32_t _SuperNET_encryptjson(struct supernet_info *myinfo,char *destfname,char wallet2shared = SuperNET_wallet2shared(wallethash,wallet2priv); wallet2pub = curve25519(wallet2shared,curve25519_basepoint9()); sprintf(destfname,"%s/%s",GLOBAL_CONFSDIR,bits256_str(str,wallet2pub)); - printf("SAVE ARGJSON.(%s) [%s, %s] -> destfname.(%s)\n",jprint(argjson,0),passphrase,fname2fa,destfname); + //printf("SAVE ARGJSON.(%s) [%s, %s] -> destfname.(%s)\n",jprint(argjson,0),passphrase,fname2fa,destfname); //printf("shared.%llx -> pub.%s\n",(long long)wallet2shared.txid,bits256_str(str,wallet2pub)); SuperNET_savejsonfile(myinfo,destfname,wallethash,wallet2pub,argjson); return(0); diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index a0c0a5274..8966ab186 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -484,6 +484,7 @@ int32_t iguana_payloadupdate(struct supernet_info *myinfo,struct iguana_info *co if ( account == 0 || account[0] == 0 ) account = "default"; payload = cJSON_DetachItemFromObject(retjson,"wallet"); + //printf("PAYLOAD.(%s)\n",jprint(payload,0)); if ( payload == 0 ) payload = cJSON_CreateObject(); if ( waddr != 0 && (valuestr= iguana_walletvalue(valuebuf,waddr)) != 0 ) @@ -499,14 +500,13 @@ int32_t iguana_payloadupdate(struct supernet_info *myinfo,struct iguana_info *co { accountobj = cJSON_CreateObject(); jadd(payload,account,accountobj); - printf("ADDACCOUNT.(%s)\n",jprint(accountobj,0)); + //printf("ADDACCOUNT.(%s)\n",jprint(accountobj,0)); } jaddstr(accountobj,rmdstr,valuestr); } jadd(retjson,"wallet",payload); newstr = jprint(retjson,1); retval = iguana_loginsave(myinfo,coin,newstr); - printf("newstr.(%s) retval.%d\n",newstr,retval); free(newstr); } else printf("iguana_payloadupdate: error parsing.(%s)\n",retstr); return(retval); @@ -540,6 +540,7 @@ cJSON *iguana_payloadmerge(cJSON *loginjson,cJSON *importjson) cJSON *iguana_walletadd(struct supernet_info *myinfo,struct iguana_waddress **waddrp,struct iguana_info *coin,char *retstr,char *account,struct iguana_waddress *refwaddr,int32_t setcurrent,char *redeemScript) { cJSON *retjson=0; struct iguana_waccount *wacct; struct iguana_waddress *waddr=0; + printf("walletaddr.(%s)\n",retstr); if ( (wacct= iguana_waccountfind(myinfo,account)) == 0 ) wacct = iguana_waccountcreate(myinfo,account); if ( wacct != 0 ) @@ -1241,7 +1242,6 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout) return(clonestr("{\"error\":\"must have password field\"}")); } iguana_walletlock(myinfo,coin); - printf("timeout.%d\n",timeout); myinfo->expiration = (uint32_t)time(NULL) + timeout; strcpy(myinfo->secret,password); strcpy(myinfo->password,password); @@ -1349,27 +1349,26 @@ TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan) memset(&addr,0,sizeof(addr)); if ( iguana_waddresscalc(myinfo,coin->chain->pubtype,coin->chain->wiftype,&addr,privkey) != 0 ) { + if ( myinfo->expiration == 0 ) + return(clonestr("{\"error\":\"need to unlock wallet\"}")); if ( (waddr= iguana_waddresssearch(myinfo,&wacct,addr.coinaddr)) != 0 ) { - waddr = iguana_waccountswitch(myinfo,coin,account,addr.coinaddr,0); + //waddr = iguana_waccountswitch(myinfo,coin,account,addr.coinaddr,0); waddr->privkey = privkey; + myinfo->dirty = 0; return(clonestr("{\"result\":\"privkey already in wallet\"}")); - } - if ( myinfo->expiration == 0 ) - return(clonestr("{\"error\":\"need to unlock wallet\"}")); + } else waddr = &addr; myinfo->expiration++; if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 ) { free(retstr); retstr = myinfo->decryptstr, myinfo->decryptstr = 0; - printf("DECRYPT.(%s)\n",retstr); - if ( waddr == 0 ) - waddr = &addr; + //printf("DECRYPT.(%s)\n",retstr); iguana_waddresscalc(myinfo,coin->chain->pubtype,coin->chain->wiftype,waddr,privkey); iguana_waccountswitch(myinfo,coin,account,waddr->coinaddr,0); waddr->privkey = privkey; retjson = iguana_walletadd(myinfo,0,coin,retstr,account,waddr,0,0); - printf("AFTERADD.(%s)\n",jprint(retjson,0)); + //printf("AFTERADD.(%s)\n",jprint(retjson,0)); if ( retstr != 0 ) scrubfree(retstr); return(jprint(retjson,1));