peerplays-network / python-peerplays

This is a communications library which allows interface with the Peerplays blockchain directly and without the need for a cli_wallet. It provides a wallet interface and can construct any kind of transactions and properly sign them for broadcast.
MIT License
22 stars 13 forks source link

Odd "createwallet" behaviour #32

Open farisshajahan opened 4 years ago

farisshajahan commented 4 years ago

The createwallet option of the peerplays CLI has a unintuitive behaviour captured below: Executing the peerplays createwallet` command to create a wallet:

$ peerplays createwallet
Wallet Passphrase: 
Repeat for confirmation: 
$

Suppose I used a passphrase of "something123".

Now rerunning the same command and giving the password as "something123" does not throw any error. This could cause confusion as to whether a wallet was created in the first place as attempting to create another wallet should've thrown the WalletExists exception.

However rerunning the same command and providing the passphrase as "somethingelse" this time throws me a WrongMasterPasswordException which proves that something was actually done when I first ran the createwallet option.

Next, say I run a peerplays addkey command. This time, the output is as follows:

No wallet installed yet. Creating ...
Wallet Encryption Passphrase:

Note how it says wallet not installed. However, providing any other passphrase other than "something123" throws a WrongMasterPasswordException. Suppose I give the passphrase as "something123", it proceeds normally on to ask me to enter a Private WIF key as follows,

Private Key (wif) [Enter to quit]:

Now if I simply press Enter and quit and rerun the addkey command once again, the same thing as above happens i.e. it still tells me "No wallet installed yet". This time however, if I do actually add a WIF key and then quit by hitting Enter, then running the addkey command later gives me the following prompt:

Current Wallet Passphrase:

Also, now, running the createwallet command and providing the passphrase as "something123" no longer exits well but throws me a WalletExists exception.

farisshajahan commented 4 years ago

The createwallet has been noticed to create a file at ~/.local/share/peerplays/peerplays.sqlite. Once we give the password "something123", it's encrypted version has also been noted to be stored in the sqlite file. However, after the first run, the file was not noticed to be read again despite running other peerplays commands. This was found out by running ls -l --time=atime ~/.local/share/peerplays/peerplays.sqlite for getting the last read time of the file.