-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add base58 and fix bech32 for is btc address #1548
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1548 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 99 99
Lines 1773 1776 +3
=========================================
+ Hits 1773 1776 +3
Continue to review full report at Codecov.
|
@@ -1,9 +1,14 @@ | |||
import assertString from './util/assertString'; | |||
|
|||
// supports Bech32 addresses | |||
const btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/; | |||
const bech32 = /^(bc1)[a-z0-9]{25,39}$/; | |||
const base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have isBase58
validator, how about re-using it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only have an issue with the reuse since:
base58
will only be needed onA-HJ-NP-Za-km-z1-9
hence we will need to add(1|3)
in front of it and check thatbase58 has 25-39 chars
.
Based on the above, I realized it will be hard to read and maintain the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, makes sense. I'm good then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fixes #1386
Checklist