-
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
Works with React Native? #582
Comments
That is a good question. I don't have the answer for you, maybe @jprichardson does.
If the results of those |
Unfortunately I don't either, I haven't been able to use React Native yet 😞 However @mvayngrib may know. |
bitcoinjs-lib works fine in react native. Currently you'll need rn-nodeify, at least until this issue is resolved. re: random number generation, the async rng uses iOS's SecRandomCopyBytes, the sync one uses a sjcl's rng seed with SecRandomCopyBytes. You'll need to evaluate the security of that for yourself. |
@mvayngrib that is interesting that they are different. |
@dcousens yep, javascript only has async access to native functions |
you'll need a piece of native code to make that work, but react-native-randombytes basically does those five lines for you: |
This thread is a gold mine. Thanks! |
ping @39otrebla, were you having issues with this? https://github.com/39otrebla/react-native-bitcoinjs-lib implies you had issues, but I can't see any difference except the |
@dcousens yeah had some issues, randomBytes does not work on ReactNative out of the box, as well as node-dependent packages.. I did need some workarounds, but now it works perfectly EDIT: differences are in ecpair.js, where I include react native randombytes package instead of node randombytes .. also, things like Buffer and streams does not work on React Native out of the box, you do need to use rn-nodeify.. The README of https://github.com/39otrebla/react-native-bitcoinjs-lib explains all step by step |
@39otrebla can you think of a way we could incorporate support into this library without you needing to maintain/rebase a separate fork? |
@39otrebla any reason why you didn't just pass in your own |
@jprichardson @mvayngrib @calvinmetcalf @dominictarr @feross @fanatid tl;dr: If we all used Thoughts? It would require quite a few changes upstream to various dependencies. I know this problem shouldn't be our responsibility, but at the same time it is just a nasty side effect of nodes implicit "non-standard" JS globals. We took the approach in https://github.com/crypto-browserify to use Maybe we can take the same initiative here (except in allowing for just a plug-and-play approach for new tools such as edit: actually, maybe disregard, this is just totally not our problem? |
@dcousens i think the initiative mostly belongs on the react-native packager end, to enable shimming / resolve-aliasing a la browserify and webpack. I currently use bitcoinjs-lib and other libs with rn-nodeify's hackery, and a bunch of native shims i co-developed with other react native fans. @philikon has developed https://github.com/philikon/ReactNativify, which is a healthier approach, but one I haven't tested yet. I suggested to him recently to try it out on bitcoinjs-lib and he said it worked: https://github.com/mvayngrib/rn-nodeify/issues/25#issuecomment-277853745 also see: https://productpains.com/post/react-native/packager-support-resolvealias-ala-webpack |
I'd be happy to merge a pr adding explicit |
if? 😃 |
sorry ... if a pull request was made to react-native to support |
@dominictarr I'm thinking of re-visiting this one - maybe adding I know it is not great, but, maybe |
@dcousens lets do it |
Closing in favour of #797 |
Does anyone know if this library will work with React Native? Theoretically any JS could should, but I wanted to know if it would operate securely, or if there were any caveats.
The text was updated successfully, but these errors were encountered: