Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: nitikeshd on December 18, 2017, 06:13:00 AM



Title: Error Code: -5, Invalid private key encoding for Litecoin Private Key
Post by: nitikeshd on December 18, 2017, 06:13:00 AM
I am using litecore-lib in nodejs.

Code:
Code: 
var pkey = new litecore.PrivateKey();
var address = pkey.toAddress();

spawn('litecoin-cli',['importprivkey',pkey]);

But it gives me Error Message:

error code: -5
error message:
Invalid private key encoding


Please Help!!?

Reference: https://github.com/litecoin-project/litecore-lib/blob/master/docs/examples.md#generate-a-random-address


Title: Re: Error Code: -5, Invalid private key encoding for Litecoin Private Key
Post by: achow101 on December 18, 2017, 03:20:01 PM
The private key is not a WIF string currently. You just have a PrivateKey object. You need to get the WIF string of the private key.