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
This looks like a bug in Electrum's software.
What you can do is manually convert the encoding to match Testnet's encoding.
- Go to http://lenschulwitz.com/base58 and enter the master public key into the Base58 Decoder
- Take the hex and change the first four bytes (first 8 characters) to match the testnet prefix:
043587CF
. - Remove the last 4 bytes (last 8 characters) from the hex string.
- Copy the modified hex and go to http://www.fileformat.info/tool/hash.htm. Enter the copied hex string into the
Hex String
field underBinary Hash
and click Hash. - Scroll down and copy the SHA256 hash. Enter that copied hash into the
Hex String
field underBinary Hash
and click Hash. - Scroll down and copy the first four bytes (first 8 characters) of the SHA256 hash.
- Append the four copied bytes onto the end of the modified hex string from earlier.
- 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.
-
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.– VladFeb 9, 2018 at 14:52