我正在尝试使用bitcoinjs-lib,但是我会出错,我认为这与使用browserify的解释有关。
为此:
import BIP32Factory from 'bip32';
const tinysecp = require('tiny-secp256k1')
const bip32 = BIP32Factory(tinysecp);我得到以下信息:
Uncaught TypeError: ecc.isPoint is not a function
at Object.testEcc (testecc.js:5:1)
at BIP32Factory (bip32.js:9:1)这里有一个替代方案,我得到了一个不同的错误:
import { Signer, SignerAsync, ECPairInterface, ECPairFactory, ECPairAPI, TinySecp256k1Interface } from 'ecpair';
const tinysecp: TinySecp256k1Interface = require('tiny-secp256k1');
const bip32: ECPairAPI = ECPairFactory(tinysecp);结果出现以下错误:
./node_modules/ecpair/src/ecpair.js 66:7
Module parse failed: Unexpected token (66:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| }
| class ECPair {
> __D;
| __Q;
| compressed;另外,我尝试过browserify bitcoinjs和ecpair,但我认为我做错了什么。
发布于 2022-05-23 15:32:04
我认为比特币- Js和tinysec不可能像现在这样工作,因为它们使用的是一些在运行时没有的Node核心功能,而这些功能在一个反应本地应用程序中是不可用的。
你可以看看:
https://github.com/novalabio/react-native-bitcoinjs-lib替代物
或
https://gist.github.com/coreyphillips/4d45160fed016417a5f583f179c2cbdb关于如何添加比特币js以使用垫片文件响应本机的讨论
https://stackoverflow.com/questions/72350903
复制相似问题