Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: pedrog on January 31, 2015, 09:50:34 PM



Title: [SOLVED] Invalid private key encoding (code -5)
Post by: pedrog on January 31, 2015, 09:50:34 PM
When trying to import a private key in Bitcoin core v0.10.0rc1 I'm getting:

Invalid private key encoding (code -5)

Address was generated at Blockchain.info.

I'm trying to import the address with:

Code:
importprivkey yourPrivateKeyInWalletImportFormat "TheLabelThatIWant"

As described here: https://en.bitcoin.it/wiki/How_to_import_private_keys_v7%2B


Title: Re: Invalid private key encoding (code -5)
Post by: Blazr on January 31, 2015, 09:53:55 PM
What is the first character of the private key?

Try importing it without a label:

Code:
importprivkey yourPrivateKeyInWalletImportFormat


Title: Re: Invalid private key encoding (code -5)
Post by: pedrog on January 31, 2015, 10:01:51 PM
What is the first character of the private key?

Try importing it without a label:

Code:
importprivkey yourPrivateKeyInWalletImportFormat

I've tried that.

I have two keys to import, one starts with 'D' the other with 'C', same error with both.


Title: Re: Invalid private key encoding (code -5)
Post by: shorena on January 31, 2015, 10:05:22 PM
What is the first character of the private key?

Try importing it without a label:

Code:
importprivkey yourPrivateKeyInWalletImportFormat

I've tried that.

I have two keys to import, one starts with 'D' the other with 'C', same error with both.

Do they end with "==" or "="? It might be encrypted.

Quote
For private keys associated with uncompressed public keys, they are 51 characters and always start with the number 5 on mainnet (9 on testnet). Private keys associated with compressed public keys are 52 characters and start with a capital L or K on mainnet (c on testnet).

https://en.bitcoin.it/wiki/Private_key


Title: Re: Invalid private key encoding (code -5)
Post by: Blazr on January 31, 2015, 10:07:31 PM
I have two keys to import, one starts with 'D' the other with 'C', same error with both.

Your private keys aren't in Wallet Import Format, they are base58 which doesn't work with Bitcoin Core.

On blockchain.info, go to import/export > export unencrypted and on the dropdown "select private key format" select "Bitcoin-Qt Format". They should begin with 5, K or L.

I have no idea why blockchain.info uses base58 as the default format, they really should change that to WIF. Almost no clients use base58.


Title: Re: Invalid private key encoding (code -5)
Post by: pedrog on January 31, 2015, 10:13:24 PM
I have two keys to import, one starts with 'D' the other with 'C', same error with both.

Your private keys aren't in Wallet Import Format, they are base58 which doesn't work with Bitcoin Core.

On blockchain.info, go to import/export > export unencrypted and on the dropdown "select private key format" select "Bitcoin-Qt Format". They should begin with 5, K or L.

That's it!!!

Thanks Blazr and shorena for your help.