bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

Single-character private key: TypeError: Number can not be equal to zero, undefined, null or false #146

Open mahnunchik opened 6 years ago

mahnunchik commented 6 years ago

Single-character private key produces the following error:

TypeError: Number can not be equal to zero, undefined, null or false
    at new PrivateKey (/test-bitcoin/node_modules/bitcore-lib/lib/privatekey.js:52:11)
    at Object.<anonymous> (/test-bitcoin/issue.js:4:13)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3

Test cases:

const bitcore = require('bitcore-lib');
// form
new bitcore.PrivateKey('1');
// to
new bitcore.PrivateKey('f');