Browse Source

fixed https://github.com/jl777/SuperNET/issues/55

problem was “password” field set but “passphrase” wasn’t
i put in a workaround to accept either
release/v0.1
jl777 8 years ago
parent
commit
6c7f3a6364
  1. 2
      iguana/iguana777.h
  2. 32
      iguana/iguana_wallet.c
  3. 4
      iguana/main.c

2
iguana/iguana777.h

@ -59,7 +59,7 @@ struct supernet_info
struct supernet_address myaddr;
bits256 persistent_priv,privkey;
uint8_t persistent_pubkey33[33];
char ipaddr[64],NXTAPIURL[512],secret[4096],rpcsymbol[64],handle[1024],permanentfile[1024];
char ipaddr[64],NXTAPIURL[512],secret[4096],password[4096],rpcsymbol[64],handle[1024],permanentfile[1024];
char *decryptstr;
int32_t maxdelay,IAMRELAY,publicRPC,basilisk_busy,genesisresults;
uint32_t expiration,dirty,DEXactive;

32
iguana/iguana_wallet.c

@ -1074,7 +1074,7 @@ STRING_ARG(bitcoinrpc,getnewaddress,account)
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
myinfo->expiration++;
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 )
{
free(retstr);
retstr = myinfo->decryptstr, myinfo->decryptstr = 0;
@ -1096,7 +1096,7 @@ struct iguana_waddress *iguana_getaccountaddress(struct supernet_info *myinfo,st
{
if ( (waddr= wacct->current) == 0 )
{
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 )
{
free(retstr);
retstr = myinfo->decryptstr, myinfo->decryptstr = 0;
@ -1153,7 +1153,11 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout)
iguana_walletlock(myinfo,coin);
printf("timeout.%d\n",timeout);
myinfo->expiration = (uint32_t)time(NULL) + timeout;
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,password,permanentfile,0);
strcpy(myinfo->secret,password);
strcpy(myinfo->password,password);
if ( permanentfile != 0 )
strcpy(myinfo->permanentfile,permanentfile);
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password);
myinfo->expiration = (uint32_t)time(NULL) + timeout;
iguana_walletinitcheck(myinfo,coin);
basilisk_unspents_update(myinfo,coin);
@ -1167,7 +1171,13 @@ THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile)
return(clonestr("{\"error\":\"no remote\"}"));
if ( password == 0 || password[0] == 0 )
password = passphrase;
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,password,permanentfile,passphrase);
else if ( passphrase == 0 || passphrase[0] == 0 )
passphrase = password;
strcpy(myinfo->secret,passphrase);
strcpy(myinfo->password,password);
if ( permanentfile != 0 )
strcpy(myinfo->permanentfile,permanentfile);
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password);
//iguana_walletlock(myinfo);
return(retstr);
}
@ -1177,13 +1187,13 @@ FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldperman
char destfname[1024],*tmpstr,*loginstr,*passphrase,*retstr = 0; cJSON *tmpjson,*loginjson;
if ( remoteaddr != 0 )
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,oldpassword)) != 0 )
{
free(tmpstr);
tmpstr = myinfo->decryptstr, myinfo->decryptstr = 0;
if ( (tmpjson= cJSON_Parse(tmpstr)) != 0 )
{
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,0)) != 0 )
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,newpassword)) != 0 )
{
if ( myinfo->decryptstr != 0 && (loginjson= cJSON_Parse(myinfo->decryptstr)) != 0 )
{
@ -1191,7 +1201,7 @@ FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldperman
{
_SuperNET_encryptjson(myinfo,destfname,passphrase,0,newpermanentfile,0,loginjson);
//iguana_walletlock(myinfo);
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,0);
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,newpassword);
}
free_json(loginjson);
}
@ -1245,7 +1255,7 @@ TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan)
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
myinfo->expiration++;
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 )
{
free(retstr);
retstr = myinfo->decryptstr, myinfo->decryptstr = 0;
@ -1308,7 +1318,7 @@ STRING_ARG(bitcoinrpc,dumpwallet,filename)
if ( myinfo->expiration != 0 )
{
myinfo->expiration++;
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
if ( (retstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
@ -1342,7 +1352,7 @@ STRING_ARG(bitcoinrpc,backupwallet,filename)
if ( myinfo->expiration != 0 )
{
myinfo->expiration++;
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 )
{
retstr = clonestr("{\"error\":\"couldnt backup wallet\"}");
if ( myinfo->decryptstr != 0 )
@ -1377,7 +1387,7 @@ STRING_ARG(bitcoinrpc,importwallet,filename)
{
if ( (importjson= cJSON_Parse(importstr)) != 0 )
{
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,0)) != 0 )
if ( (loginstr= SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password)) != 0 )
{
free(loginstr);
loginstr = myinfo->decryptstr, myinfo->decryptstr = 0;

4
iguana/main.c

@ -1442,11 +1442,12 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase)
safecopy(myinfo->permanentfile,permanentfile,sizeof(myinfo->permanentfile));
if ( (decryptstr= SuperNET_decryptjson(IGUANA_CALLARGS,password,myinfo->permanentfile)) != 0 )
{
printf("decryptstr.(%s)\n",decryptstr);
if ( (argjson= cJSON_Parse(decryptstr)) != 0 )
{
if ( jobj(argjson,"error") == 0 )
{
//printf("decrypted.(%s) exp.%u pass.(%s)\n",decryptstr,myinfo->expiration,password);
printf("decrypted.(%s) exp.%u pass.(%s)\n",decryptstr,myinfo->expiration,password);
if ( myinfo->decryptstr != 0 )
free(myinfo->decryptstr);
myinfo->decryptstr = decryptstr;
@ -1502,6 +1503,7 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase)
if ( (str= SuperNET_encryptjson(myinfo,coin,argjson,remoteaddr,password,myinfo->permanentfile,myinfo->decryptstr == 0 ? "" : myinfo->decryptstr)) != 0 )
free(str);
myinfo->expiration = (uint32_t)(time(NULL) + 3600);
printf("(%s) logged into (%s) %s %s\n",password,myinfo->myaddr.NXTADDR,myinfo->myaddr.BTC,myinfo->myaddr.BTCD);
return(SuperNET_activehandle(IGUANA_CALLARGS));
} else return(clonestr("{\"error\":\"need passphrase\"}"));
printf("(%s) logged into (%s) %s %s\n",password,myinfo->myaddr.NXTADDR,myinfo->myaddr.BTC,myinfo->myaddr.BTCD);

Loading…
Cancel
Save