Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
6d38aeed18
  1. 2
      iguana/SuperNET_keys.c
  2. 21
      iguana/iguana_wallet.c

2
iguana/SuperNET_keys.c

@ -309,7 +309,7 @@ int32_t _SuperNET_encryptjson(struct supernet_info *myinfo,char *destfname,char
wallet2shared = SuperNET_wallet2shared(wallethash,wallet2priv); wallet2shared = SuperNET_wallet2shared(wallethash,wallet2priv);
wallet2pub = curve25519(wallet2shared,curve25519_basepoint9()); wallet2pub = curve25519(wallet2shared,curve25519_basepoint9());
sprintf(destfname,"%s/%s",GLOBAL_CONFSDIR,bits256_str(str,wallet2pub)); 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)); //printf("shared.%llx -> pub.%s\n",(long long)wallet2shared.txid,bits256_str(str,wallet2pub));
SuperNET_savejsonfile(myinfo,destfname,wallethash,wallet2pub,argjson); SuperNET_savejsonfile(myinfo,destfname,wallethash,wallet2pub,argjson);
return(0); return(0);

21
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 ) if ( account == 0 || account[0] == 0 )
account = "default"; account = "default";
payload = cJSON_DetachItemFromObject(retjson,"wallet"); payload = cJSON_DetachItemFromObject(retjson,"wallet");
//printf("PAYLOAD.(%s)\n",jprint(payload,0));
if ( payload == 0 ) if ( payload == 0 )
payload = cJSON_CreateObject(); payload = cJSON_CreateObject();
if ( waddr != 0 && (valuestr= iguana_walletvalue(valuebuf,waddr)) != 0 ) 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(); accountobj = cJSON_CreateObject();
jadd(payload,account,accountobj); jadd(payload,account,accountobj);
printf("ADDACCOUNT.(%s)\n",jprint(accountobj,0)); //printf("ADDACCOUNT.(%s)\n",jprint(accountobj,0));
} }
jaddstr(accountobj,rmdstr,valuestr); jaddstr(accountobj,rmdstr,valuestr);
} }
jadd(retjson,"wallet",payload); jadd(retjson,"wallet",payload);
newstr = jprint(retjson,1); newstr = jprint(retjson,1);
retval = iguana_loginsave(myinfo,coin,newstr); retval = iguana_loginsave(myinfo,coin,newstr);
printf("newstr.(%s) retval.%d\n",newstr,retval);
free(newstr); free(newstr);
} else printf("iguana_payloadupdate: error parsing.(%s)\n",retstr); } else printf("iguana_payloadupdate: error parsing.(%s)\n",retstr);
return(retval); 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 *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; cJSON *retjson=0; struct iguana_waccount *wacct; struct iguana_waddress *waddr=0;
printf("walletaddr.(%s)\n",retstr);
if ( (wacct= iguana_waccountfind(myinfo,account)) == 0 ) if ( (wacct= iguana_waccountfind(myinfo,account)) == 0 )
wacct = iguana_waccountcreate(myinfo,account); wacct = iguana_waccountcreate(myinfo,account);
if ( wacct != 0 ) if ( wacct != 0 )
@ -1241,7 +1242,6 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout)
return(clonestr("{\"error\":\"must have password field\"}")); return(clonestr("{\"error\":\"must have password field\"}"));
} }
iguana_walletlock(myinfo,coin); iguana_walletlock(myinfo,coin);
printf("timeout.%d\n",timeout);
myinfo->expiration = (uint32_t)time(NULL) + timeout; myinfo->expiration = (uint32_t)time(NULL) + timeout;
strcpy(myinfo->secret,password); strcpy(myinfo->secret,password);
strcpy(myinfo->password,password); strcpy(myinfo->password,password);
@ -1349,27 +1349,26 @@ TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan)
memset(&addr,0,sizeof(addr)); memset(&addr,0,sizeof(addr));
if ( iguana_waddresscalc(myinfo,coin->chain->pubtype,coin->chain->wiftype,&addr,privkey) != 0 ) 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 ) 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; waddr->privkey = privkey;
myinfo->dirty = 0;
return(clonestr("{\"result\":\"privkey already in wallet\"}")); return(clonestr("{\"result\":\"privkey already in wallet\"}"));
} } else waddr = &addr;
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
myinfo->expiration++; myinfo->expiration++;
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 ) if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 )
{ {
free(retstr); free(retstr);
retstr = myinfo->decryptstr, myinfo->decryptstr = 0; retstr = myinfo->decryptstr, myinfo->decryptstr = 0;
printf("DECRYPT.(%s)\n",retstr); //printf("DECRYPT.(%s)\n",retstr);
if ( waddr == 0 )
waddr = &addr;
iguana_waddresscalc(myinfo,coin->chain->pubtype,coin->chain->wiftype,waddr,privkey); iguana_waddresscalc(myinfo,coin->chain->pubtype,coin->chain->wiftype,waddr,privkey);
iguana_waccountswitch(myinfo,coin,account,waddr->coinaddr,0); iguana_waccountswitch(myinfo,coin,account,waddr->coinaddr,0);
waddr->privkey = privkey; waddr->privkey = privkey;
retjson = iguana_walletadd(myinfo,0,coin,retstr,account,waddr,0,0); 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 ) if ( retstr != 0 )
scrubfree(retstr); scrubfree(retstr);
return(jprint(retjson,1)); return(jprint(retjson,1));

Loading…
Cancel
Save