<p>This looks like a bug in Electrum's software.</p>

<p>What you can do is manually convert the encoding to match Testnet's encoding. </p>

<ol>
<li>Go to <a href="http://lenschulwitz.com/base58" rel="nofollow noreferrer">http://lenschulwitz.com/base58</a> and enter the master public key into the Base58 Decoder</li>
<li>Take the hex and change the first four bytes (first 8 characters) to match the testnet prefix: <code>043587CF</code>.</li>
<li>Remove the last 4 bytes (last 8 characters) from the hex string.</li>
<li>Copy the modified hex and go to <a href="http://www.fileformat.info/tool/hash.htm" rel="nofollow noreferrer">http://www.fileformat.info/tool/hash.htm</a>. Enter the copied hex string into the <code>Hex String</code> field under <code>Binary Hash</code> and click Hash.</li>
<li>Scroll down and copy the SHA256 hash. Enter that copied hash into the <code>Hex String</code> field under <code>Binary Hash</code> and click Hash.</li>
<li>Scroll down and copy the first four bytes (first 8 characters) of the SHA256 hash.</li>
<li>Append the four copied bytes onto the end of the modified hex string from earlier.</li>
<li>Enter the full modified hex string (with changed prefix and changed suffix) into the Base58 encoder on <a href="http://lenschulwitz.com/base58" rel="nofollow noreferrer">http://lenschulwitz.com/base58</a> and Encode it. The result will be a <code>tpub</code> which is valid.</li>
</ol>

CC BY-SA 3.0
2017-11-26T18:16:49.113Z
Thank you for detailed steps, I can report that it worked. Before that I actually tried the [following JS snippet](https://gist.github.com/jeryini/161ac33833e4d9b6812a755ad1cd8c62) 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.
Jernej Jerin
CC BY-SA 3.0
2018-02-09T14:52:14.597Z
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
CC BY-SA 3.0
2017-11-26T17:35:10.590Z
2017-11-26T17:35:10.590Z
Ava Chow
<p>I'm running Electrum in test mode (<code>electrum --testnet</code>) 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 <code>xpub</code>, which doesn't make sense as according to <a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer">this site</a> it should start with <code>tpub</code>. 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.</p>

<electrum><public-key><testnet>
Electrum TESTNET public key
Jernej Jerin
# Electrum TESTNET public key

(Asked by: username_0 on 2017-11-26)

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](https://en.bitcoin.it/wiki/List_of_address_prefixes) 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.

**Tags:** electrum, public-key, testnet


---

## 1 answers

### Answer by username_1 on 2017-11-26. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_0**: Thank you for detailed steps, I can report that it worked. Before that I actually tried the [following JS snippet](https://gist.github.com/jeryini/161ac33833e4d9b6812a755ad1cd8c62) 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.  
> **username_2**: 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.  

---

