Function to Parse Bitcoin Wallet Import Format => Fails
Closed this issue · 2 comments
node test.js
/home/users/test.js:4
console.log(res.version.toString('hex')) // => 80
^
TypeError: Cannot call method 'toString' of undefined
at Object. (/home/user/test.js:4:25)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3
while the script is just like in the example:
var cs = require('coinstring');
var wif = "5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD"
var version = 0x80 //Bitcoin private key
var fromBtcWif = cs.createDecoder(version)
//later in your program
console.log(fromBtcWif(wif).payload.toString('hex'))
// => 51184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd
I'm not sure that I understand what problem you're describing... what is res
in your code?
Closing for lack of response.