Advanced Bitcoin Scripting - Discussion

Hmmm, good question. I did some googling, as I’m sure you have too, and found this: https://github.com/nodejs/node-gyp/issues/809.

There are a lot of different solutions there that worked for different people. You can try some of them. Many people got it to work by making sure they have no spaces in their filepath, deleting the .node-gyp folder and then restarting the computer.

Let me know if any of it works.

1 Like

Hi Filip,

U are teh man, bro :rocket:

These steps helped me to solve my issue:

  • use node 11.10.0
  • went to …/AppData/Roaming/nvm/v11.10.0/node_modules/npm/node_modules and deleted the node-gyp folder
  • npm install -g node-gyp@latest
    (this installs node-gyp in AppData/Roaming/nvm/v11.10.0/node_modules/ and NOT in the folder mentioned above)
  • went to my project and deleted node_modules folder as wells as package-lock.json
  • “npm i” in project folder
  • “npm i bcoin” in project folder

Can’t wait to finally finish up this course and start with LN :smiley:

1 Like

NIIIIIIICEEEEE. I’m happy you are able to progress. Good luck :slight_smile:

PS C:> cd .\Users\Utente\multisigproject
PS C:\Users\Utente\multisigproject> npm install bcoin

[email protected] install C:\Users\Utente\multisigproject\node_modules\leveldown
prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=12.13.0 runtime=node arch=ia32 platform=win32)

C:\Users\Utente\multisigproject\node_modules\leveldown>if not defined npm_config_node_gyp (node “C:\Program Files\nodejs
\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\…\node_modules\node-gyp\bin\node-gyp.js” rebuild ) else
(node “C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” rebuild )
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if “python” can be used
gyp ERR! find Python - “python” is not in PATH or produced an error
gyp ERR! find Python checking if “python2” can be used
gyp ERR! find Python - “python2” is not in PATH or produced an error
gyp ERR! find Python checking if “python3” can be used
gyp ERR! find Python - “python3” is not in PATH or produced an error
gyp ERR! find Python checking if the py launcher can be used to find Python 2
gyp ERR! find Python - “py.exe” is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Python27\python.exe
gyp ERR! find Python - “C:\Python27\python.exe” could not be run
gyp ERR! find Python checking if Python is C:\Python37\python.exe
gyp ERR! find Python - “C:\Python37\python.exe” could not be run
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python=“C:\Path\To\python.exe”
gyp ERR! find Python (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python npm config set python “C:\Path\To\python.exe”
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack at PythonFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.
js:307:47)
gyp ERR! stack at PythonFinder.runChecks (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-py
thon.js:136:21)
gyp ERR! stack at PythonFinder. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-
python.js:225:16)
gyp ERR! stack at PythonFinder.execFileCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib
find-python.js:271:16)
gyp ERR! stack at exithandler (child_process.js:302:5)
gyp ERR! stack at ChildProcess.errorhandler (child_process.js:314:5)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! stack at onErrorNT (internal/child_process.js:456:16)
gyp ERR! stack at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\bin\node-gyp.js” “rebuild”
gyp ERR! cwd C:\Users\Utente\multisigproject\node_modules\leveldown
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: prebuild-install || node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Utente\AppData\Roaming\npm-cache_logs\2019-11-19T02_39_31_541Z-debug.log
PS C:\Users\Utente\multisigproject>

I don’t have python installed but node.js…
I kept trying to run this on admin mode but it’s still giving me errors.

What am I doing wrong?

Ok, I think I have found a clue why this isn’t working…First of all, downgrading to node 11.10.0.
I have tried the leveldown command but this is what powershell is telling me:

PS C:\users\utente\multisigproject> npm install -g [email protected]

> [email protected] preinstall C:\Users\Utente\AppData\Roaming\npm\node_modules\node
> node installArchSpecificPackage

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"win32","arch":"x86"} (current: {"os":"win32
","arch":"ia32"})
npm ERR! notsup Valid OS:    win32
npm ERR! notsup Valid Arch:  x86
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: ia32

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Utente\AppData\Roaming\npm-cache\_logs\2019-11-25T16_41_05_454Z-debug.log
internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module 'node-win-x86/package.json'

Could it be because my laptop doesn’t run the X86 architecture? Yes it’s a bit old…

Help please, I am stuck on this…I can’t seem to find anything working, I tried all the steps describe above like deleting folders and try downloading the latest versions but I still get the same messages…

I am going to follow the rest of the course even if I will not be able to repeat the steps on my laptop…@filip, I need only one piece of advice:

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"win32","arch":"x86"} (current: {"os":"win32
","arch":"ia32"})
npm ERR! notsup Valid OS:    win32
npm ERR! notsup Valid Arch:  x86

Could this be the reason why it isn’t working?

Have you tried installing python?

Yes, I have the latest version (Python 3) installed which npm couldn’t locate. As a response to that, I downloaded Python 2 and it finally recognised it. Then it asked me about visual studio with the C++ extensions and I did download the 2017 version with the windows package.

I also had visual studio installed before re downloading it with the packages… I don’t understand why it’s so hard for it to recognize components.

After completing the above steps, this is what I currently get by typing the command “npm install bcoin”:

PS C:\> cd .\Users\Utente\multisigproject
PS C:\Users\Utente\multisigproject> npm install bcoin

> [email protected] install C:\Users\Utente\multisigproject\node_modules\mrmr
> node-gyp rebuild || echo 'Build failed.'


C:\Users\Utente\multisigproject\node_modules\mrmr>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node
_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node
 "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
  File "<string>", line 1
    'from
        ^
SyntaxError: EOL while scanning string literal
gyp: Call to 'python -c 'from __future__ import print_function; import sys; print(sys.byteorder)'' returned exit status
1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configur
e.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node
-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Utente\multisigproject\node_modules\mrmr
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
'Build failed.'

> [email protected] install C:\Users\Utente\multisigproject\node_modules\secp256k1
> npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."


> [email protected] rebuild C:\Users\Utente\multisigproject\node_modules\secp256k1
> node-gyp rebuild


C:\Users\Utente\multisigproject\node_modules\secp256k1>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs
\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else
(node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Compilazione dei progetti nella soluzione uno alla volta. Per abilitare la compilazione parallela, aggiungere l'opzione
"/m".
  addon.cc
  privatekey.cc```
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with
 exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:1
94:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node
-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Utente\multisigproject\node_modules\secp256k1
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Utente\AppData\Roaming\npm-cache\_logs\2019-11-28T15_29_21_075Z-debug.log
"Secp256k1 bindings compilation fail. Pure JS implementation will be used."

> [email protected] install C:\Users\Utente\multisigproject\node_modules\leveldown
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=12.13.0 runtime=node arch=ia32 platform=win32)

C:\Users\Utente\multisigproject\node_modules\leveldown>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs
\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else
(node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Compilazione dei progetti nella soluzione uno alla volta. Per abilitare la compilazione parallela, aggiungere l'opzione
"/m".
  builder.cc
  db_impl.cc
  db_iter.cc
  filename.cc
  dbformat.cc
  log_reader.cc
  log_writer.cc
  memtable.cc
  repair.cc
  table_cache.cc
  version_edit.cc
  version_set.cc
  write_batch.cc
  memenv.cc
  port_posix_sse.cc
  block.cc
  block_builder.cc
  filter_block.cc
  format.cc
  iterator.cc
  merger.cc
  table.cc
  table_builder.cc
  two_level_iterator.cc
  arena.cc
  bloom.cc
  cache.cc
  coding.cc
  comparator.cc
  crc32c.cc
  env.cc
  filter_policy.cc
  hash.cc
  logging.cc
  options.cc
  status.cc
  port_uv.cc
  env_win.cc
  win_logger.cc
  win_delay_load_hook.cc
  leveldb.vcxproj -> C:\Users\Utente\multisigproject\node_modules\leveldown\build\Release\\leveldb.lib
  snappy-sinksource.cc
  snappy-stubs-internal.cc
  snappy.cc
  win_delay_load_hook.cc
  snappy.vcxproj -> C:\Users\Utente\multisigproject\node_modules\leveldown\build\Release\\snappy.lib
  batch.cc
  batch_async.cc
  c:\users\utente\appdata\local\node-gyp\cache\12.13.0\include\node\v8.h(3402): note: vedere la dichiarazione di 'v8::O
  bject::Set' (compilazione del file di origine ..\src\leveldown_async.cc)
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with
 exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:1
94:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node
-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Utente\multisigproject\node_modules\leveldown
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Utente\multisigproject\package.json'
npm WARN multisigproject No description
npm WARN multisigproject No repository field.
npm WARN multisigproject No README data
npm WARN multisigproject No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Utente\AppData\Roaming\npm-cache\_logs\2019-11-28T15_32_28_676Z-debug.log
PS C:\Users\Utente\multisigproject>



and to be honest, i had to cut much of the error code it was giving me because it couldn’t even fit the max words allowed here…

Hmm, I’m not sure what’s going on here. Seems like something is deeply wrong with your npm. I would try to completely remove node and npm and then download a new fresh version from node https://nodejs.org/en/.

I’m sorry I don’t have a final solution for you. But this is what I would have done.

1 Like

No worries, It’s very difficult to diagnose this one…I’ve been trying for days now. It could also be that my machine is quite old, either way, I’ll follow your suggestion and try to erase/reinstall everything. In case it doesn’t still work, I’ll just follow the rest of the course with a notepad and a pen :wink:

1 Like

BOOM! SORTED! It turns out that you had a final solution for me…I reinstalled everything from scratch and I’ve beautifully created the 2 private keys… Thanks buddy :wink:

2 Likes

Wow amazing! So glad you managed to solved it!!

Regarding the bonus section of the advanced bitcoin scripting…
Wouldn’t it be more secure to use hardware wallet while generating private keys?
I know you are trying to teach how this all works in regtest but in reality creating private keys in this fashion is a disaster waiting to happen.

1 Like

maybe you could generate keys on a laptop using Linux that never went online.

1 Like

That isn’t practical which is why Hardware wallets are popular.
Also to make sure a machine never goes online is difficult.

1 Like

It’s not that hard to make sure a machine never goes online. But I agree that it is safer to use a hardware wallet to generate keys.

2 Likes

Let’s say you disconnected the computer from your network.
How are you going to download files to it? A USB memory stick or a CD ?
Malicious code can still be transferred to the offline computer via USB.
The differentiator between the two isn’t online VS offline.
Hardware wallets have a very limited interface. You cannot expose the private key from them unless the hardware itself is tempered with. It also has a limited feature which is to sign transactions & that is it.
It simply cannot do anything else unless an unofficial malicious firmware is uploaded to it which is pretty hard to do.

1 Like

you can also generate keys using some Javascript code. you can always type it over. But you make a good point if you copy stuff.

2 Likes

I got problems with bcoin on my Macbook.
I followed the source install from https://bcoin.io/guides/install-mac.html
When I execute: node address.js
at line: const Keyring = bcoin.wallet.WalletKey;
I get the following error:

/Users/aw/dev/bitcoin/bcoin/node_modules/loady/lib/loady.js:123
throw err;
^
Error: Could not locate the bindings file. Tried:

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/build/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/build/Debug/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/build/Release/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/out/Debug/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/Debug/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/out/Release/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/Release/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/build/default/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/compiled/12.14.0/darwin/x64/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/addon-build/release/install-root/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/addon-build/debug/install-root/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/addon-build/default/install-root/leveldown.node

  • /Users/aw/dev/bitcoin/bcoin/node_modules/bdb/lib/binding/node-v72-darwin-x64/leveldown.node

at bindings (/Users/aw/dev/bitcoin/bcoin/node_modules/loady/lib/loady.js:118:15)

1 Like

Hmm, I can’t find the page you linked to. Have they deleted it?

Did you run npm install in your directory? You could try removing the node_modules file and then re-running npm install.