faker
faker copied to clipboard
Generated bitcoin addresses should pass validators.isBtcAddress
Clear and concise description of the problem
In #1181 the question came up, whether our bitcoin generator produces valid bitcoin addresses. According to validators.isBtcAddress it doesn't do so all the time.
Suggested solution
We should
- check whether the validator.js method is correct,
- use it in our tests,
- and verify that the tests pass.
Alternative
No response
Additional context
No response
I would like to try contribute to this issue if it still hasn't been resolved. Can you assign to me?
I would like to try contribute to this issue if it still hasn't been resolved. Can you assign to me?
Sure!
@import-brain I took the regex from our tests and manually verified it at https://regexr.com/ I believe our bitcoin address generation is wrong. Should we install the validatorjs package and apply it to bitcoin address tests with bitcoin address generation fix?
It's allowing the
i
character
@import-brain
I took the regex from our tests and manually verified it at https://regexr.com/
I believe our bitcoin address generation is wrong.
Should we install the validatorjs package and apply it to bitcoin address tests with bitcoin address generation fix?
It's allowing the
i
character
Sure, go for it!
@ST-DDT @import-brain
I've searched a little and I verified that lowercase i
is permitted, the difference of validator.js and our validation on tests is the max chars.
Validator.js validation https://github.com/validatorjs/validator.js/blob/86a07ba4f3f710f639e92a62cf81dd3321ef9ee8/src/lib/isBtcAddress.js#L5
Our validation https://github.com/faker-js/faker/blob/fda44bb899efbcbac2071a199964a3e269cbd805/test/finance.spec.ts#L293
And i verified that the max generated chars is different of our tests and validator.js https://github.com/faker-js/faker/blob/15e3eed927953446d3e3aa8dcd7fca3f8472ff3e/src/modules/finance/index.ts#L214
I don't know say which is correct, I searched and almost all of the sites don't says the same thing about valid bitcoin address
I don't know say which is correct, I searched and almost all of the sites don't says the same thing about valid bitcoin address
Yeah, pretty much all websites say different things about the max and min lengths of bitcoin addresses.
I don't know say which is correct, I searched and almost all of the sites don't says the same thing about valid bitcoin address
Yeah, pretty much all websites say different things about the max and min lengths of bitcoin addresses.
Yep. We should keep how many to min and max? Because, basically this is the diffeference of validatorjs
I don't know say which is correct, I searched and almost all of the sites don't says the same thing about valid bitcoin address
Yeah, pretty much all websites say different things about the max and min lengths of bitcoin addresses.
Yep. We should keep how many to min and max? Because, basically this is the diffeference of validatorjs
It's really confusing. At the top of the Bitcoin wiki page on addresses, it says that Bitcoin addresses contain "27-34 alphanumeric Latin characters (except 0, O, I)". However, further down the same page, it says "Some Bitcoin addresses can be shorter than 34 characters (as few as 26) and still be valid".
Maybe needs decision :thinking:
Team decision
- We will use validatorJs for validation and will pass that library (or any other well known validation library).
Okay @ST-DDT. I will apply the necessary changes to conform to the validatorJs validations
PR: #1375