Skip to content
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

Can I use bitcoin-core in the browser? #79

Open
takahser opened this issue Nov 6, 2018 · 0 comments
Open

Can I use bitcoin-core in the browser? #79

takahser opened this issue Nov 6, 2018 · 0 comments

Comments

@takahser
Copy link

takahser commented Nov 6, 2018

I was wondering, if it's possible to use this library in the browser. Currently, I use bitcoinjs-lib in a VUE.js app to build transactions and I intend to use bitcoin-core for connecting to the network and broadcast the already signed transactions.

To test the integration, I'm using this simple code:

const Client = require('bitcoin-core');

const client = new Client({
  host: 'localhost',
  port: 1337,
  username: 'alice',
  password: 'foo'
});

client.getBlockchainInfo((error, help) => {
  console.log('info: ', help);
  console.log('error: ', error);
});

For testing, I ran it in 3 different apps:

  • a node.js app => worked perfectly
  • a VUE app => I get an error in the browser, whenever I call functions on the bitcoin core client:
TypeError: Failed to fetch
    at _bluebird.default.try (webpack-internal:///./node_modules/bitcoin-core/dist/src/index.js:168:27)
From previous event:
    at Client.command (webpack-internal:///./node_modules/bitcoin-core/dist/src/index.js:154:33)
    at apply (webpack-internal:///./node_modules/lodash/lodash.js:475:27)
    at Client.wrapper [as getBlockchainInfo] (webpack-internal:///./node_modules/lodash/lodash.js:5323:16)
    at eval (webpack-internal:///./src/services/wallet/btc-wallet.service.ts:78:8)
    at Module../src/services/wallet/btc-wallet.service.ts (http://localhost:8080/app.js:14817:1)
    at __webpack_require__ (http://localhost:8080/app.js:768:30)
    at fn (http://localhost:8080/app.js:131:20)
// etc.
  • an angular app => I get this error, which occur, when node packages are used in the browser, that depend on certain node functions, which the browser doesn't implement, as explained here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant