Disallow PubKey as PrivKey for cmd_set_default_account
command - display error if user accidentally pass wrong key.
#1645
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Validate input to
cmd_set_default_account
, ensuring we don't accidentally pass in PublicKey instead of PrivateKey.Details
In
main
it is possible to accidentally pass in the PublicKey to the PrivateKey value for commandcmd_set_default_account
. This results in confusing state and error when trying to e.g. perform a transfer.N.B: we don't get any information on what went wrong, that is because of the program panics at unwrap at line 62, so we never reach the next line, with more info:
Error::NoDefaultPrivateKey
. This should also be fix (I can do another PR), but this PR fixes so that should never happen...I got into this state since I accidentally copied the PublicKey instead of the PrivateKey, resulting in this bad state.
Testing
Now it is not possible to pass in the PublicKey instead of PrivateKey anymore, and we display a very informative error
GotPublicKeyExpectedPrivateKey
.Added a unit test.