importprivkey encoding error after upgrading version

+2 votes

Hi,

I attempted to upgrade from version 1.0.2 to 1.0.4. As part of the process I want to restore some of the addresses I had generated in version 1.0.2. I did this using the dumpprivkey and importprivkey commands. However when attempting to import on version 1.0.4 I got an error for invalid encoding.

I had a look at the release notes and couldn't see anything that suggested this changed. Below is a snippet of the commands I attempted with a new throwaway address for demo purposes:

MultiChain 1.0.2 RPC client

chain: getaddresses

{"method":"getaddresses","params":[],"id":1,"chain_name":"chain"}

[

    "16JLPZwAWwVYkcVxXxtZGBsDLern484DXYEBY6"

]

chain: importprivkey VExNnWvTx9Ukhn7SP1MFXm3DwfnY6wkXGkx3edps3Li76JJQNMP7XE4a

{"method":"importprivkey","params":["VExNnWvTx9Ukhn7SP1MFXm3DwfnY6wkXGkx3edps3Li76JJQNMP7XE4a"],"id":1,"chain_name":"chain"}

 

chain: getaddresses

{"method":"getaddresses","params":[],"id":1,"chain_name":"chain"}

 

[

    "16JLPZwAWwVYkcVxXxtZGBsDLern484DXYEBY6",

    "1Ma3NdCE55aNaG3ha5vC5qxMJqmVMTyruN5W51"

]

 

MultiChain 1.0.4 RPC client

chain: getaddresses

{"method":"getaddresses","params":[],"id":1,"chain_name":"chain"}

[

    "1Uo2R6Fcjx6MsiM5Kj3tgdf6UfdfjipXP6z1W8"

]

chain: importprivkey VExNnWvTx9Ukhn7SP1MFXm3DwfnY6wkXGkx3edps3Li76JJQNMP7XE4a

{"method":"importprivkey","params":["VExNnWvTx9Ukhn7SP1MFXm3DwfnY6wkXGkx3edps3Li76JJQNMP7XE4a"],"id":1,"chain_name":"chain"}

 

error code: -5

error message:

Invalid private key encoding

Could you offer any advice? For now I can postpone upgrading, no major rush on a response.

I tried quoting the value and also base64 encoding it.

Kind regards,

John

asked May 11, 2018 by John

1 Answer

+1 vote
 
Best answer
The most likely explanation here is that you started a new blockchain under 1.0.4. By default each blockchain has its own version bytes for encoding addresses and private keys, to help prevent accidents in which a transaction intended for one chain is performed on another.

You can however copy across the relevant parameters from one chain to a new one (before starting the new chain, of course). See this page for more details: https://www.multichain.com/developers/address-key-format/
answered May 13, 2018 by MultiChain
This is exactly what I was looking for, thank you.
...