Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Prompt error if vanity pattern is not valid base58 #5308

Merged
merged 3 commits into from
Mar 19, 2020

Conversation

lwshang
Copy link
Contributor

@lwshang lwshang commented Mar 19, 2020

The vanity subcommand of subkey will search for an address with a pattern. Since the address are subject to base58 encoding, the characters in the pattern should also narrow to base58. Otherwise the search will never end which is the current behaviour.

This PR fix the problem by prompting an error when user provide an invalid pattern.

@parity-cla-bot
Copy link

It looks like @lwshang signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shawntabrizi shawntabrizi added A0-please_review Pull request needs code review. A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update). labels Mar 19, 2020
bin/utils/subkey/src/vanity.rs Outdated Show resolved Hide resolved
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test.

@lwshang
Copy link
Contributor Author

lwshang commented Mar 19, 2020

Can you please add a test.

Sure, I will.

In PolkadotJS, user can choose whether they want "case sensitive" or not. Do I need to check how will that be influenced by this PR?

@bkchr
Copy link
Member

bkchr commented Mar 19, 2020

If a capital L is forbidden, it should be tested as well.

@lwshang
Copy link
Contributor Author

lwshang commented Mar 19, 2020

Capital L is allowed in base58. So in subkey vanity, patterns contain L is valid.

From my understanding, subkey itself currently doesn't support case insensitive directly. I speculate that PolkadotJS has some mechanism to expand search cases. Therefore, I think it's meaningful to have a check on their code to see their implementation.

@bkchr
Copy link
Member

bkchr commented Mar 19, 2020

@jacogr can you shed some light on case sensitive here?

@jacogr
Copy link
Contributor

jacogr commented Mar 19, 2020

All the UI does is to lowercase the whole thing when doing a match, if so requested. No magic there.

@lwshang
Copy link
Contributor Author

lwshang commented Mar 19, 2020

All the UI does is to lowercase the whole thing when doing a match, if so requested. No magic there.

Just read your code, the PolkadotJS is more versatile. I would like to improve subkey with similar capabilities in the future.

@bkchr bkchr merged commit c98ce97 into paritytech:master Mar 19, 2020
bkchr added a commit that referenced this pull request Mar 24, 2020
* Prompt error if vanity pattern is not valid base58

* Update bin/utils/subkey/src/vanity.rs

* Add tests for validating pattern of subkey vanity

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
romanb pushed a commit to romanb/substrate that referenced this pull request Apr 2, 2020
* Prompt error if vanity pattern is not valid base58

* Update bin/utils/subkey/src/vanity.rs

* Add tests for validating pattern of subkey vanity

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. A2-insubstantial Pull request requires no code review (e.g., a sub-repository hash update).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants