Closed ph101pp closed 5 months ago
Spent a lot of time on this but it works correctly in react native 0.74.2.
You will need to create a reproducible repo with exact code which is breaking.
Thank you for your time!
I created this repo with expo
setup that reproduces the error:
https://github.com/ph101pp/expo-scure-btc-signer/
The problem doesn't seem to be with react-native
itself, but with expo
and most likely the metro
bundler that it is using: https://github.com/facebook/metro
Expo is the standard when it comes to building production level react-native apps, it would be amazing if @scure/btc-signer
could work with this setup, but so far I wasn't able to get it to work.
We don't support Buffer
s. You must always use Uint8Array. Something somewhere would break, because buffer is shit. For example, it completely redefines semantics of slice to make it like subarray instead of copy.
I wasn't aware of that re: Buffers! Thanks!
Turns out that fastestsmallesttextencoderdecoder
TextDecoder shim isn't up to full spec / only supports utf-8
for speed purposes ( I'm assuming that is the issue). Replacing the shim fixed the issue.
Other shims that make similar compromises suggest to use Buffer
for other types of conversions, but after your comment above I'm assuming using TextDecoder was a deliberate choice.
Thanks again for your time and sorry for the churn, I was banging my head against the table.
Hello!
Thank you for your work on the scure libraries, they work great!
That said, I'm having trouble getting
btc.Transaction.fromPSBT
working inreact-native@0.74.2
Other things work great: Creating
btc.selectUTXO
,tx.toPSBT
, justbtc.Transaction.fromPSBT
fails with:Thrown somewhere in
decodeStream
.We have polyfills for
crypto
,TextEncode
/TextDecode
,Buffer
,stream
etc.This same code works in a web environment with the same inputs.
Any input/help would be appreciated!
This might be an issue for micro-packed instead. Let me know and I can open an issue there.