Hi Alko,
I tried with the version I had installed, 10.21.0, however this did not work. Then when trying to change default on my module list I encountered problems so after some searching I deleted all node, nodejs and npm from my system and installed nvm from github nvm-sh/nvm.
I have installed and tried these LTS… 10.23.0, 12.20.0, 14.15.3, but get errors every time. The same errors as the students on here.
I tried 12.18.3 and 12.16.3 after reading on here that they worked but still no joy.
I have only just noticed a post of yours from October, saying that bcoin doesnt work with npm anymore and that we should use git instead.
Is this what we have to do now?
Hey you should install the bcoin library manually, not through npm. This part of the course is being re-recorded at the moment since there has been quite a bit of changes in the library.
https://github.com/bcoin-org/bcoin/blob/master/docs/getting-started.md
Ok, cool.
So, I ran;
git clone git://github.com/bcoin-org/bcoin.git
Then
cd bcoin
What next? As the npm rebuild, install etc dont work.
What error do you get? You don’t really need to install it globally, you can import sources from the cloned directory.
Sorry… I was getting hung up on an alternative to npm for installing bcoin (Im still quite new to all this).
So, now I have a directory called bcoin. If I type bcoin in my terminal from any location, it starts a node. Ctrl + c stops it.
Now, do I work from inside the bcoin directory or create the multisigproject directory as per the course? As the node_module directory will not be created inside multisigproject directory as I have not used npm init or npm install bcoin from inside multisigproject. so, the files that would be created already exist inside the bcoin directory.
Thanks in advance
For this example you don’t really need to have a npm project. All you need is to have bcoin installed either globaly or locally in a folder.
Personally I would just clone the repository in the project folder and rebuild it, but if you installed it globaly it should be fine as well.
You can now create *.js files by Filips instructions and import the library and it should work. Bear in mind the addresses from his example haven’t been updated yet and you will have to create your own bech32 addresses. You can use bitcoind
or bcoin
for that since bcoin also features a Bitcoin node as well.
I did clone the repository which created the bcoin directory. If I enter bcoin in a terminal window, it starts the node, so that is all fine.
What I was asking was, do I still have to create the multisigproject directory or do I just use the bcoin directory?
Either way should be fine, you will only create a few files in multisig. I Imagined you would clone bcoin into multisig folder.
Ahhhh I was in my home directory when I cloned it. I’m learning all the time.
Thanks very much again for your help.
Its not that important really. Let me know if it works. New videos are going to be available in a few weeks.
It worked fine. Im not getting any errors. If I type bcoin
in my terminal, it starts a node.
Thanks again.
The only thing I cant get my head around is that npm no longer works for installing bcoin but as per the bcoin-org github page, I had to type in npm rebuild
after cloning the repo.
The npm package is no longer maintained afaik because of apparent security issues. Their official installation instructions now recommend installing bcoin using git.
I have had a few problems with installing bcoin. With a big thanks to Alko89 and search engines I would like to document what worked for me as a newbie who thought it would be a good idea to use Centos8 as I had installed it to do a command line course a few months ago as my tech journey began. I’m not trying to say that what I’m going to share is the correct way to do things… only that it worked for me. So…
I already had nodejs installed from a previous course but soon ran into problems when trying to change streams. After a few long hours searching and trying unsuccessfully, I found nvm (node version manager), this will allow you to see a (long) list of previous nodejs versions including which are LTS, and download and use/set a set default.
To download and run the install script
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
Then type command -v
which should output nvm or try; nvm -v
which should output 0.37.2
If this doesn’t work, close the terminal window, open a new one and try again either of these two commands again.
To see a full list of nodejs versions available for download, type nvm ls-remote
; to install a specific version, type nvm install <version number>
; and to switch to a previously downloaded version, type nvm use <version number>
.
Now, back to the course.
mkdir multisigproject
cd multisigproject
git clone git://github.com/bcoin-org/bcoin.git
npm rebuild
npm install --global
Then type bcoin
from any location and a node will start, ctrl + c
to stop it.
Without using everyone of these commands I got errors.
Hopefully this can help someone out.
It’s not over yet tho. After finally finding solutions to all the problems I was having, I stumbled across the news that Centos is not going to be a long term OS for me, or for anybody. So, I decided to switch back to Ubuntu which was my first Linux distro in when I started in June this year.
The good news is that there is only one extra step at the beginning, which is…
sudo apt-get install build-essentials python
As I said at the start, I’m not saying this is what should be done… but I worked for me. Feel free to correct me or advise in any way.
If you’re using nvm you could just use the old node version that Filip used in the course, that should work as well.
The problem with nvm is it doesn’t work on Windows that most of the students are using.
Yeah, true, although I had issues with the node version that was already installed on my system, and then trouble changing stream. So, nvm seems to have been the best solution for me as a Linux user.
I’ve never used windows in my life and don’t intend to. I use OSX for Ableton Live. That was my only computing experience before I started with Linux, which I now love.
Hi Alko, I now need some help with this part.
In Part2, he uses ‘regtest’ which throws errors when trying to create and export the keypairs. I tried it just to see for myself.
Where can I find the script that I need to use ‘bech32’ instead?
Ohh thats great! I have been using Linux for 8+ years now and am also enjoying it a lot. Sorry to hear about using macos
You can use either bitcoind
of bcoin
to generate bech32 addresses and you can use a txid from previous examples.
I mean for this part… If I’ve not to use regtest in this script, what do I put in its place?
'use strict'
const fs = require('fs');
const bcoin = require('bcoin');
const KeyRing = bcoin.wallet.WalletKey;
const Script = bcoin.Script;
//Create 2 private keys
const keypair1 = KeyRing.generate(true, 'regtest');
const keypair2 = KeyRing.generate(true, 'regtest');
//Export keypairs
fs.writeFileSync('regtest-key1.wif', keypair1.toSecret('regtest'));
fs.writeFileSync('regtest-key2.wif', keypair2.toSecret('regtest'));
You don’t need to do anything here. If you run the script two keys will be created, you can check them out in regtest-key.wif
files or simply print them to console.
I get errors when I run node address.js
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'bcoin'
Require stack:
- /home/mark/multisigproject/address.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/mark/multisigproject/address.js:4:15)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/mark/multisigproject/address.js' ]
}