Git Product home page Git Product logo

Comments (9)

Alf71 avatar Alf71 commented on September 12, 2024 1

Thanks

from btc_stuff.

antonilol avatar antonilol commented on September 12, 2024

Did you npm install?

from btc_stuff.

Alf71 avatar Alf71 commented on September 12, 2024

Yes, both:

npm install bitcoinjs-lib
npm install ecpair

from btc_stuff.

antonilol avatar antonilol commented on September 12, 2024

Which script did you try to run?
Which OS do you have and which node and npm version do you run?

What does require('ecpair') print in nodejs repl?

from btc_stuff.

Alf71 avatar Alf71 commented on September 12, 2024

Ubuntu Server 18 running in Win10
priv_key_recovery.js
Node.js v14.16.1

`
node priv_key_recovery.js
/home/admin/recover/priv_key_recovery.js:2
const ECPair = require('ecpair').ECPairFactory(require('tiny-secp256k1'));
^

TypeError: require(...).ECPairFactory is not a function
at Object. (/home/admin/recover/priv_key_recovery.js:2:34)
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)
at internal/main/run_main_module.js:17:47`

from btc_stuff.

antonilol avatar antonilol commented on September 12, 2024

i cant reproduce this (archlinux)
i tried the exact nodejs version (v14.16.1)

what does node -pe "require('ecpair')" print?
i get { default: [Getter], ECPairFactory: [Getter], networks: [Getter] } (it should include the ECPairFactory)

what version op ecpair do you have installed?
i have 2.0.1:

$ cat node_modules/ecpair/package.json | grep version
  "version": "2.0.1",

from btc_stuff.

Alf71 avatar Alf71 commented on September 12, 2024

I'm getting

{
networks: {
bitcoin: {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bech32: 'bc',
bip32: [Object],
pubKeyHash: 0,
scriptHash: 5,
wif: 128
},
testnet: {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bech32: 'tb',
bip32: [Object],
pubKeyHash: 111,
scriptHash: 196,
wif: 239
}
},
ECPair: [class ECPair]
}

from btc_stuff.

Alf71 avatar Alf71 commented on September 12, 2024

cat node_modules/ecpair/package.json | grep version
cat: node_modules/ecpair/package.json: No such file or directory

from btc_stuff.

antonilol avatar antonilol commented on September 12, 2024

looks like a really old version of bitcoinjs lib and ecpair
i think this patch will fix it but consider updating your node/npm

diff --git a/priv_key_recovery.js b/priv_key_recovery.js
index 35fd65d..40b68db 100644
--- a/priv_key_recovery.js
+++ b/priv_key_recovery.js
@@ -1,5 +1,5 @@
 const bitcoin = require('bitcoinjs-lib');
-const ECPair = require('ecpair').ECPairFactory(require('tiny-secp256k1'));
+const { ECPair } = require('ecpair');
 
 const base58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'.split('');

from btc_stuff.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.