Comments (7)
Thanks, how do you mean I can't open
test.html
in the browser directly? Note that I'm running this in an offline environment, just on my local computer (that doesn't run a webserver). It always worked like this with previous BitcoinJS versions (v5 and earlier) but I think since v6 there have been some changes resulting in this browser incompatibility.Note that it works fine if I comment the
const ecc
line, it's just this particulartiny-secp256k1
that seems to cause an issue when using in a browserified package (this was not the case with previous versions).I'm not sure sure what you mean by the second option. Note that I don't use any wasm file myself, it's just the code from one of the libraries used in BitcoinJS, I use it as-is. I'd rather not manually change it or mess with its internals, otherwise I'll have the same trouble whenever I update to a newer version.
use @bitcoinerlab/secp256k1 replace tiny-secp256k1
have a try
from bitcoinjs-lib.
@bitcoinerlab/secp256k1
is a great alternative implementation that works well with browser bundlers.
WASM support in bundlers is still very iffy.
@bitcoinjs-lib/tiny-secp256k1-asmjs
is also available, but a bit slower than bitcoinerlab. But it is generated from the WASM.
from bitcoinjs-lib.
use @bitcoinerlab/secp256k1 replace tiny-secp256k1 have a try
Thanks! That did the trick! 👍
P.S. may I suggest to include this in the using bitcoinjs-lib in browser instructions as I can imagine it may save people a lot of troubleshooting.
Much appreciated! 🙏
from bitcoinjs-lib.
The first option, you need to use bundle.js
in an environment, like http://localhost:3000
or https://google.com/web3
, but do not use the file like index.html
opened in the browser directly, it won't work in this way.
The second option, find the error position like(0 , fs_1.readFileSync)
and annotate the code, and replace it by loading the wasm file through fetch
.
from bitcoinjs-lib.
Thanks, how do you mean I can't open test.html
in the browser directly? Note that I'm running this in an offline environment, just on my local computer (that doesn't run a webserver). It always worked like this with previous BitcoinJS versions (v5 and earlier) but I think since v6 there have been some changes resulting in this browser incompatibility.
Note that it works fine if I comment the const ecc
line, it's just this particular tiny-secp256k1
that seems to cause an issue when using in a browserified package (this was not the case with previous versions).
I'm not sure sure what you mean by the second option. Note that I don't use any wasm file myself, it's just the code from one of the libraries used in BitcoinJS, I use it as-is. I'd rather not manually change it or mess with its internals, otherwise I'll have the same trouble whenever I update to a newer version.
from bitcoinjs-lib.
If you are using tiny-secp256k1, undoutedly, it uses wasm file because the library was built by Rust. So when you load it in your test.html
, the js environment needs to fetch the wasm file at first. Simply speaking, remove the fs
and replace it by fetch
.
By the way, if you are use @bitcoinerlab/secp256k1
which already removed the wasm file, hence, there shouldn't be an issue occurred like you posted fs_1.readFileSync not found
. I suggest you search the fs
module in your output bundle script, and check what's going on there because there's no wasm indeed.
from bitcoinjs-lib.
use @bitcoinerlab/secp256k1 replace tiny-secp256k1 have a try
Thanks! That did the trick! 👍
P.S. may I suggest to include this in the using bitcoinjs-lib in browser instructions as I can imagine it may save people a lot of troubleshooting.
Much appreciated! 🙏
https://github.com/bitcoinjs/tiny-secp256k1#alternatives
It is mentioned on tiny-secp256k1.
Please make a suggestion as to how you would change it, pull requests to update READMEs etc. are always welcome (even if they tend to get bike-sheddy)
from bitcoinjs-lib.
Related Issues (20)
- Sign rawtransaction does not work: Non-witness UTXO hash for input #0 doesn't match the hash specified in the prevout HOT 2
- How can I generate nonWitnessUtxo for signTransaction? HOT 11
- reactnative generate address error HOT 7
- How can I run a test for just one file with a specific name? HOT 1
- Sign message got different result between with .sign() and wallet signMessage( ) HOT 11
- How to recover btc address from txn witness data? HOT 5
- Apply for manage issues HOT 1
- attach "hello world" in transaction using bitcoinjs-lib HOT 1
- 258: txn-mempool-conflict HOT 6
- Stack and Script visualize HOT 1
- [Question] How to watch blocks like viem.watchBlocks? HOT 5
- toASM throws TypeError: Cannot read properties of null (reading 'map') HOT 4
- offline signing with multiple utxos from different addresses HOT 3
- Question: Bitcoinjs-lib will support Testnet4? HOT 4
- Function to determine address type by address or redeemScript HOT 1
- Psbt.signInput Passed but Broadcast Failure with msg `non-mandatory-script-verify-flag (Witness program hash mismatch)` HOT 5
- How to make taproot P2TR multiSig wallet HOT 3
- Error when deserializing a PSBT HOT 6
- Getting non-mandatory-script-verify-flag (Invalid Schnorr signature) on taproot key path spending with LEDGER nano HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitcoinjs-lib.