-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 new type to allow toBase58Check to get string in browser #2069
Fix: add new type to allow toBase58Check to get string in browser #2069
Conversation
@jasonandjay @johngame @junderw PTAL. |
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.
Hello, thank you for this. Maybe you could consider editing your PR description to mention that this PR fixes #openissue
so that it can indicate automatically what issue the PR is closing.
Thanks, I've updated the description. Do we recently plan to upgrade it to esm module? Maybe I could join our community. |
Hey, I am not sure about this. I think one of the maintainers will provide better insight into that. |
I don't understand what you're trying to do. // This is your code
const encoder = new TextEncoder();
const hash = encoder.encode('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')
/*
hash is Uint8Array(34) [
49, 66, 103, 71, 90, 57, 116, 99, 78,
52, 114, 109, 57, 75, 66, 122, 68, 110,
55, 75, 112, 114, 81, 122, 56, 55, 83,
90, 50, 54, 83, 65, 77, 72
] */ The input to Why are you creating a UTF8 array with the UTF8 data for a string address? This whole PR makes zero sense to me. I don't understand what you're trying to do, I don't understand why the random github io link is relevant, and I don't understand why the PR is taking a hex string when your example is trying to input a Uint8Array....... Please fix the PR, or your body to make sense, and then I'll look at it again. If I ignore your PR body and only look at the code, I would reject this because the API isn't for handling strings, and Buffer.from(xyz, 'hex') has weird behavior when an invalid string is input. |
Underlying Reason:
Reason for this modification:
Handling hexadecimal strings: hash = Buffer.isBuffer(hash) ? hash : Buffer.from(hash, 'hex'); This revised code snippet and explanation should address the concerns raised. By clarifying the need for flexibility in input types and simplifying integration across different environments, we ensure that the PR aligns better with user expectations and practical functionality. |
strings are not how you should deal with binary data. Closing in favor of #1855 which is currently being worked on by a few Summer of Bitcoin participants. |
Issue:
fixes #2070
Aim:
Reason:
Link: https://jasonandjay.github.io/bitcoinjs-lib/functions/address.fromBase58Check.html
Code: