Browse Source

test

etomic
jl777 8 years ago
parent
commit
2bf7b29ea9
  1. 9
      iguana/SuperNET_keys.c
  2. 1
      iguana/iguana_rpc.c
  3. 2
      iguana/iguana_wallet.c

9
iguana/SuperNET_keys.c

@ -84,7 +84,6 @@ bits256 SuperNET_wallet2priv(char *wallet2fname,bits256 wallethash)
wallet2str[i] ^= wallethash.bytes[(i + r) % 32];
vcalc_sha256(0,wallet2priv.bytes,(void *)wallet2str,(int32_t)allocsize);
free(wallet2str);
//char str[65]; printf("wallet2priv.(%s) from.(%s) crc.%u and passphrase r.%d len.%ld\n",bits256_str(str,wallet2priv),wallet2fname,crc,r,allocsize);
} else if ( wallet2fname[0] != 0 )
printf("SuperNET_wallet2priv cant open (%s)\n",wallet2fname);
return(wallet2priv);
@ -248,7 +247,6 @@ cJSON *SuperNET_decryptedjson(char *destfname,char *passphrase,int32_t passsize,
wallethash = SuperNET_linehash(passphrase);
SuperNET_linehash(fname2fa); // maps special chars
wallet2priv = SuperNET_wallet2priv(fname2fa,wallethash);
//char str[65],str2[65]; printf("(%s + %s) -> wallethash.%s 2.(%s)\n",passphrase,fname2fa,bits256_str(str,wallethash),bits256_str(str2,wallet2priv));
}
first = (bits256_nonz(wallethash) != 0 && bits256_cmp(wallethash,GENESIS_PRIVKEY) != 0);
second = (bits256_nonz(wallet2priv) != 0 && bits256_cmp(wallet2priv,GENESIS_PRIVKEY) != 0);
@ -259,7 +257,6 @@ cJSON *SuperNET_decryptedjson(char *destfname,char *passphrase,int32_t passsize,
wallet2shared = SuperNET_wallet2shared(wallethash,wallet2priv);
wallet2pub = curve25519(wallet2shared,curve25519_basepoint9());
sprintf(destfname,"%s/%s",GLOBAL_CONFSDIR,bits256_str(str,wallet2pub));
//printf("fname.(%s) wallet2pub.%s < [%s, %s]\n",destfname,bits256_str(str,wallet2pub),passphrase,fname2fa);
if ( (confstr= OS_filestr(&allocsize,destfname)) != 0 )
{
if ( (filejson= cJSON_Parse(confstr)) != 0 )
@ -305,12 +302,9 @@ int32_t _SuperNET_encryptjson(struct supernet_info *myinfo,char *destfname,char
wallethash = SuperNET_linehash(passphrase);
SuperNET_linehash(fname2fa); // maps special chars
wallet2priv = SuperNET_wallet2priv(fname2fa,wallethash);
//char str2[65]; printf("ENCRYPT.[%s %s] (%s) 2.%s\n",passphrase,fname2fa,bits256_str(str,wallethash),bits256_str(str2,wallet2priv));
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("shared.%llx -> pub.%s\n",(long long)wallet2shared.txid,bits256_str(str,wallet2pub));
SuperNET_savejsonfile(myinfo,destfname,wallethash,wallet2pub,argjson);
return(0);
}
@ -375,7 +369,6 @@ char *SuperNET_keysinit(struct supernet_info *myinfo,char *argjsonstr)
passphrase[0] = fname2fa[0] = 0;
wallethash = wallet2priv = GENESIS_PRIVKEY;
coinargs = SuperNET_parsemainargs(myinfo,&wallethash,&wallet2priv,argjsonstr);
//printf("wallethash.%s 2.(%s)\n",bits256_str(str,wallethash),bits256_str(str2,wallet2priv));
if ( (msgjson= SuperNET_decryptedjson(destfname,passphrase,sizeof(passphrase),wallethash,fname2fa,sizeof(fname2fa),wallet2priv)) != 0 )
{
SuperNET_parsemyinfo(myinfo,msgjson);
@ -395,9 +388,7 @@ char *SuperNET_keysinit(struct supernet_info *myinfo,char *argjsonstr)
jaddbits256(json,"persistent_pub",myinfo->myaddr.persistent);
OS_randombytes((void *)&r,sizeof(r));
jadd64bits(json,"rand",r);
//printf("call SuperNET_encryptjson\n");
_SuperNET_encryptjson(myinfo,destfname,passphrase,sizeof(passphrase),fname2fa,sizeof(fname2fa),json);
//printf("save.(%s)\n",jprint(json,0));
free_json(json);
}
if ( myinfo->ipaddr[0] == 0 )

1
iguana/iguana_rpc.c

@ -52,7 +52,6 @@ char *sglue(GLUEARGS,char *agent,char *method)
{
if ( (wallet= iguana_walletjson(myinfo)) != 0 )
{
//printf("WALLETSTR.(%s)\n",jprint(wallet,0));
if ( (walletstr= SuperNET_login(myinfo,coin,json,remoteaddr,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
{
free(walletstr);

2
iguana/iguana_wallet.c

@ -1505,12 +1505,10 @@ TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan)
{
free(retstr);
retstr = myinfo->decryptstr, myinfo->decryptstr = 0;
//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));
if ( retstr != 0 )
scrubfree(retstr);
return(jprint(retjson,1));

Loading…
Cancel
Save