matja / bitcoin-tool

Tool for converting Bitcoin keys and addresses
206 stars 116 forks source link

Private key too short #54

Closed bhultin-dev closed 3 years ago

bhultin-dev commented 3 years ago

Hi,

I am using the tool to derive dogecoin private keys from 64bit hex values for import into multidoge. However the generated keys are 50 (sometimes 51) characters and multidoge exported keys have 53 characters. Any ideas?

Here is the command I'm running:

bitcoin-tool --batch --network dogecoin --input-type private-key --input-format hex --input-file ../recovered-keys.txt --output-type private-key --output-format base58check --public-key-compression uncompressed

Thanks.

streamofstars commented 3 years ago

My personal interest with this tool is related to Bitcoin only, so frankly I'm not eager to install Multidoge to test that issue. However, I spent a few minutes googling and found this old topic in Multidoge github https://github.com/langerhans/multidoge/issues/27 it seems very similar to yours. Long story short, those Multidoge keys are probably in WIF format and what you are doing here is converting hex-encoded private keys to base58check-encoded private keys. Try converting them to WIFs ie. --output-type private-key-wif --output-format base58check Also, remember that hex-encoded private key is universal but WIF keys are targetting specific compression, so you probably need to convert each hex-encoded private key twice: first to uncompressed WIF key and second to compressed WIF key and import both to Multidoge. A side note, I am not familiar with Dogecoin development details so I'm not sure if they support both types (un/compressed).

bhultin-dev commented 3 years ago

Thank you! Using --output-type private-key-wif with --public-key-compression compressed did the trick. Using uncompressed creates wifs starting with 6 which work in Exodus which supports importing 1 at a time.

For anyone who might stumble upon this later: Creates keys/wifs starting with Q, 53 characters, works with multidoge: bitcoin-tool --batch --network dogecoin --input-type private-key --input-format hex --input-file [path to file] --output-type private-key-wif --output-format base58check --public-key-compression compressed

Creates keys/wifs starting with 6, 52 characters, works with Exodus: bitcoin-tool --batch --network dogecoin --input-type private-key --input-format hex --input-file [path to file] --output-type private-key-wif --output-format base58check --public-key-compression uncompressed