0

I'm running Electrum in test mode (electrum --testnet) and have therefore created a new wallet for it. I've also successfully received some coins via Faucet. But when checking the public key for the wallet, it starts with xpub, which doesn't make sense as according to this site it should start with tpub. How can I get the right public key, as I need it for some online service (mycelium GEAR) and it's complaining that this is a key for MAINNET.

1 Answer 1

3

This looks like a bug in Electrum's software.

What you can do is manually convert the encoding to match Testnet's encoding.

  1. Go to http://lenschulwitz.com/base58 and enter the master public key into the Base58 Decoder
  2. Take the hex and change the first four bytes (first 8 characters) to match the testnet prefix: 043587CF.
  3. Remove the last 4 bytes (last 8 characters) from the hex string.
  4. Copy the modified hex and go to http://www.fileformat.info/tool/hash.htm. Enter the copied hex string into the Hex String field under Binary Hash and click Hash.
  5. Scroll down and copy the SHA256 hash. Enter that copied hash into the Hex String field under Binary Hash and click Hash.
  6. Scroll down and copy the first four bytes (first 8 characters) of the SHA256 hash.
  7. Append the four copied bytes onto the end of the modified hex string from earlier.
  8. Enter the full modified hex string (with changed prefix and changed suffix) into the Base58 encoder on http://lenschulwitz.com/base58 and Encode it. The result will be a tpub which is valid.
2
  • Thank you for detailed steps, I can report that it worked. Before that I actually tried the following JS snippet to generate public key from seed but it failed. Care to take a look why it doesn't generate the right one? Thanks once again. Nov 26, 2017 at 18:16
  • Unfortunately, Electrum won't accept the "tpub" key to use for deriving other keys. :( Version 3.0.6 of electrum is what I tested with.
    – Vlad
    Feb 9, 2018 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.