<p>When you are deriving addresses, you are actually deriving private or public keys from which an address is derived. However addresses are actually an encoding of what type of script to use in the output, but private keys have no concept of what scripts are. So when you derive your keys, they don't specify what type of address to create. Each private key can actually correspond to multiple addresses.</p>

<p>To specify what kind of address to create, your wallet software must be able to understand what the derivation paths mean or be able to be told what kind of address to be created. Just using a derivation path for keys which were used to derive one type of address does not mean that all software will create the same addresses.</p>

<p>You will need to use a software that knows how to create the address type you want and then you need to be able to tell it to do that.</p>

CC BY-SA 3.0
2018-02-23T04:56:40.123Z
2018-02-23T04:56:40.123Z
Ava Chow
<p>@AndrewChow♦ explained it nicely.</p>

<p>Another way to see the relationship between keys and addresses is directly using litecoind, if you have one handy.</p>

<pre><code>$ litecoin-cli getaddressesbyaccount ""
[returns list (A) of addresses or none]
$ litecoin-cli getnewaddress ""
[returns a fresh new address ADDR1]
$ litecoin-cli getaddressesbyaccount ""
[returns list of addresses (A) + single entry for ADDR1]
$ litecoin-cli dumpprivkey &lt;ADDR1&gt;
[returns private key PRIV1 that ADDR1 came from]
$ litecoin-cli importprivkey &lt;PRIV1&gt;
[returns nothing]
$ litecoin-cli getaddressesbyaccount ""
[returns list of addresses (A) + ADDR1 + two extra representations]
</code></pre>

<p>That last call to <code>getaddressesbyaccount ""</code> shows that when importing a private key, the daemon adds all possible addresses that correspond to it.</p>

<p>The private key in litecoin's case corresponds to:</p>

<ul>
<li>a p2pkh address (legacy, non-Segwit): starts with 'L'</li>
<li>a p2sh address (wrapped Segwit): starts with 'M'</li>
<li>a bech32 address (pure Segwit): starts with 'ltc'</li>
</ul>

<p><em>Note</em>: the <code>ADDR1</code> returned by <code>getnewaddress</code> will either be an 'L' address or an 'M' address depending on whether the daemon's config contains <code>addresstype=legacy</code> or not respectively. You could optionally define on the command line the type of address you want generated:\</p>

<pre><code>$ getnewaddress "" legacy/p2sh-segwit/bech32
</code></pre>

<p><em>Note 2</em>: as you might have noticed litecoind  (recent versions) avoids altogether the old p2sh addresses starting with '3' as they are trying to get people to move away from them and towards 'M' ones, to avoid further confusion with bitcoin's '3' addresses.</p>

CC BY-SA 4.0
2019-04-03T19:20:40.247Z
2019-04-03T19:34:08.257Z
2019-04-03T19:34:08.257Z
thalisk
<p>So I'm trying to get my head around this!</p>

<ol>
<li>I've got my 24 seed for my Trezor.</li>
<li>I got my Segwit account for LTC (Address starts with M).</li>
<li>I also have the P2H equivalent for my address (Starts with 3).</li>
</ol>

<p>How do I derive using the BIP39? I tried, and I ended up with addresses that start with L. (Legacy ones).</p>

<p>m/49'/2'/0'/0    --> this one is for M Segwit LTC <br>
m/44'/2'/0'/0    ---> this one is for Legacy LTC </p>

<litecoin><segregated-witness><trezor><private-key-export><mnemonic-seed>
Derive LTC Segwit (M-Address) private key from Trezor
Dragoo
# Derive LTC Segwit (M-Address) private key from Trezor

(Asked by: username_0 on 2018-02-21)

So I'm trying to get my head around this!

1. I've got my 24 seed for my Trezor.
2. I got my Segwit account for LTC (Address starts with M).
3. I also have the P2H equivalent for my address (Starts with 3).

How do I derive using the BIP39? I tried, and I ended up with addresses that start with L. (Legacy ones).

m/49'/2'/0'/0 --> this one is for M Segwit LTC   
m/44'/2'/0'/0 ---> this one is for Legacy LTC

**Tags:** litecoin, segregated-witness, trezor, private-key-export, mnemonic-seed


---

## 2 answers

### Answer by username_1 on 2018-02-23. Score: 3

When you are deriving addresses, you are actually deriving private or public keys from which an address is derived. However addresses are actually an encoding of what type of script to use in the output, but private keys have no concept of what scripts are. So when you derive your keys, they don't specify what type of address to create. Each private key can actually correspond to multiple addresses.

To specify what kind of address to create, your wallet software must be able to understand what the derivation paths mean or be able to be told what kind of address to be created. Just using a derivation path for keys which were used to derive one type of address does not mean that all software will create the same addresses.

You will need to use a software that knows how to create the address type you want and then you need to be able to tell it to do that.


---

### Answer by username_2 on 2019-04-03. Score: 0

@AndrewChow♦ explained it nicely.

Another way to see the relationship between keys and addresses is directly using litecoind, if you have one handy.

```
$ litecoin-cli getaddressesbyaccount ""
[returns list (A) of addresses or none]
$ litecoin-cli getnewaddress ""
[returns a fresh new address ADDR1]
$ litecoin-cli getaddressesbyaccount ""
[returns list of addresses (A) + single entry for ADDR1]
$ litecoin-cli dumpprivkey <ADDR1>
[returns private key PRIV1 that ADDR1 came from]
$ litecoin-cli importprivkey <PRIV1>
[returns nothing]
$ litecoin-cli getaddressesbyaccount ""
[returns list of addresses (A) + ADDR1 + two extra representations]

```

That last call to `getaddressesbyaccount ""` shows that when importing a private key, the daemon adds all possible addresses that correspond to it.

The private key in litecoin's case corresponds to:

* a p2pkh address (legacy, non-Segwit): starts with 'L'
* a p2sh address (wrapped Segwit): starts with 'M'
* a bech32 address (pure Segwit): starts with 'ltc'

*Note*: the `ADDR1` returned by `getnewaddress` will either be an 'L' address or an 'M' address depending on whether the daemon's config contains `addresstype=legacy` or not respectively. You could optionally define on the command line the type of address you want generated:\

```
$ getnewaddress "" legacy/p2sh-segwit/bech32

```

*Note 2*: as you might have noticed litecoind (recent versions) avoids altogether the old p2sh addresses starting with '3' as they are trying to get people to move away from them and towards 'M' ones, to avoid further confusion with bitcoin's '3' addresses.


---

