Author

Topic: Error Code: -5, Invalid private key encoding for Litecoin Private Key (Read 98 times)

staff
Activity: 3374
Merit: 6530
Just writing some code
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.
newbie
Activity: 22
Merit: 1
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
Jump to: