<p>I assume both the Python library and Trustwallet implement BIP32 to create hierarchical deterministic (HD) wallets.</p>
<p>The address you get depends on the <a href="https://bitcoin.stackexchange.com/q/78993/13866">derivation path</a>. If your Python library and Trustwallet use different derivation paths, you will get different addresses.</p>
<p>An HD wallet will produce multiple addresses, a different one each time you request an address. So you must be careful not to compare the 1st address from one wallet with the 2nd address from another.</p>

CC BY-SA 4.0
2021-10-16T22:49:14.733Z
2021-10-16T22:54:16.813Z
2021-10-16T22:54:16.813Z
RedGrittyBrick
<p>Thank you.
I independently found libraries that generate the same address as Trust Wallet, as well as Cryptoneed (Mobile Apps).
Who needs my code, copy and customize for yourself:</p>
<pre><code>from hdwallet import BIP44HDWallet
from hdwallet.utils import generate_mnemonic
from hdwallet.derivations import BIP44Derivation
from hdwallet.cryptocurrencies import BitcoinMainnet, EthereumMainnet
from bip_utils import Bip84, Bip84Coins, Bip44Changes, Bip39SeedGenerator


LanguageInMnemonic = &quot;english&quot;

Mnemonic = generate_mnemonic(language = LanguageInMnemonic, strength = 128)
    Seed = Bip39SeedGenerator(Mnemonic).Generate()

    print(Mnemonic)

    if IsCheckBTC == &quot;+&quot;:
        if IsCheckBTCBip44 == &quot;+&quot;:
            CheckedWalletBTCBip44 = BIP44HDWallet(cryptocurrency=BitcoinMainnet)
            CheckedWalletBTCBip44.from_mnemonic(mnemonic = Mnemonic, language = LanguageInMnemonic, passphrase = None)
            CheckedWalletBTCBip44.clean_derivation()
            CheckedWalletBTCBip44Derivation = BIP44Derivation(cryptocurrency = BitcoinMainnet, account = 0, change = False, address = 0)
            CheckedWalletBTCBip44.from_path(path = CheckedWalletBTCBip44Derivation)

            CheckedAddressBTCBip44 = CheckedWalletBTCBip44.address()
            print(CheckedAddressBTCBip44)

        if IsCheckBTCBip84 == &quot;+&quot;:
            CheckedWalletBTCBip84 = Bip84.FromSeed(Seed, Bip84Coins.BITCOIN)
            CheckedWalletBTCBip84Step1 = (CheckedWalletBTCBip84.Purpose().Coin().Account(0)).Change(Bip44Changes.CHAIN_EXT)
            CheckedWalletBTCBip84Step2 = CheckedWalletBTCBip84Step1.AddressIndex(0)

            CheckedAddressBTCBip84 = CheckedWalletBTCBip84Step2.PublicKey().ToAddress()
            print(CheckedAddressBTCBip84)

    if IsCheckETH == &quot;+&quot;:
        CheckedWalletETH = BIP44HDWallet(cryptocurrency = EthereumMainnet)
        CheckedWalletETH.from_mnemonic(mnemonic = Mnemonic, language = LanguageInMnemonic, passphrase = None)
        CheckedWalletETH.clean_derivation()
        CheckedWalletETHDerivation: BIP44Derivation = BIP44Derivation(cryptocurrency = EthereumMainnet, account = 0, change = False, address = 0)
        CheckedWalletETH.from_path(path=CheckedWalletETHDerivation)

        CheckedAddressETH = CheckedWalletETH.address()
        print(CheckedAddressETH)
</code></pre>
<p>(P. S. I used google translate)</p>

CC BY-SA 4.0
2022-07-04T13:18:06.917Z
Why is the definition of IsCheckBTC not defined in your code snippet???
HMN
CC BY-SA 4.0
2021-10-17T18:05:31.260Z
2021-10-18T09:19:43.337Z
2021-10-18T09:19:43.337Z
Андрей
<p>Please you i get a php version of this code instead of Python.
I have a seed Phrase. I want the BTC address that correspond with Blockchain.
I want code in PHP so that i can modify to suit my project</p>

CC BY-SA 4.0
2023-09-04T02:28:05.383Z
2023-09-04T02:28:05.383Z
EHIS E
<p>Faced a problem, I have a crypto wallet written in Python, there is a code that creates a wallet address from a mnemonic phrase (In this case, BTC address). But if I enter this mnemonic phrase into the Trust Wallet mobile app, it will give me a completely different Bitcoin address. Why? How to fix it? Here is the code:</p>
<pre><code>from bipwallet import wallet
from bipwallet.utils import *

Seed = wallet.generate_mnemonic()

WalletBTC = wallet.create_wallet(network=&quot;BTC&quot;, seed=Seed, children=0)

AddressBTC = WalletBTC.get(&quot;address&quot;)

print(&quot;BTC Address: &quot;, AddressBTC)
</code></pre>

CC BY-SA 4.0
2021-10-16T22:47:43.250Z
The derivation path must be the same too not just the mnemonic
Mike D
<python><mnemonic-seed><seed>
How to get correct address from BTC mnemonic phrase in Python
Андрей
# How to get correct address from BTC mnemonic phrase in Python

(Asked by: username_0 on 2021-10-16)

Faced a problem, I have a crypto wallet written in Python, there is a code that creates a wallet address from a mnemonic phrase (In this case, BTC address). But if I enter this mnemonic phrase into the Trust Wallet mobile app, it will give me a completely different Bitcoin address. Why? How to fix it? Here is the code:

```
from bipwallet import wallet
from bipwallet.utils import *

Seed = wallet.generate_mnemonic()

WalletBTC = wallet.create_wallet(network="BTC", seed=Seed, children=0)

AddressBTC = WalletBTC.get("address")

print("BTC Address: ", AddressBTC)

```

**Tags:** python, mnemonic-seed, seed

> **Comments:**
> **username_1**: The derivation path must be the same too not just the mnemonic  

---

## 3 answers

### Answer by username_2 on 2021-10-16. Score: 2

I assume both the Python library and Trustwallet implement BIP32 to create hierarchical deterministic (HD) wallets.

The address you get depends on the [derivation path](https://bitcoin.stackexchange.com/q/78993/13866). If your Python library and Trustwallet use different derivation paths, you will get different addresses.

An HD wallet will produce multiple addresses, a different one each time you request an address. So you must be careful not to compare the 1st address from one wallet with the 2nd address from another.


---

### Answer by username_0 on 2021-10-17. Score: 1

Thank you.
I independently found libraries that generate the same address as Trust Wallet, as well as Cryptoneed (Mobile Apps).
Who needs my code, copy and customize for yourself:

```
from hdwallet import BIP44HDWallet
from hdwallet.utils import generate_mnemonic
from hdwallet.derivations import BIP44Derivation
from hdwallet.cryptocurrencies import BitcoinMainnet, EthereumMainnet
from bip_utils import Bip84, Bip84Coins, Bip44Changes, Bip39SeedGenerator

LanguageInMnemonic = "english"

Mnemonic = generate_mnemonic(language = LanguageInMnemonic, strength = 128)
    Seed = Bip39SeedGenerator(Mnemonic).Generate()

    print(Mnemonic)

    if IsCheckBTC == "+":
        if IsCheckBTCBip44 == "+":
            CheckedWalletBTCBip44 = BIP44HDWallet(cryptocurrency=BitcoinMainnet)
            CheckedWalletBTCBip44.from_mnemonic(mnemonic = Mnemonic, language = LanguageInMnemonic, passphrase = None)
            CheckedWalletBTCBip44.clean_derivation()
            CheckedWalletBTCBip44Derivation = BIP44Derivation(cryptocurrency = BitcoinMainnet, account = 0, change = False, address = 0)
            CheckedWalletBTCBip44.from_path(path = CheckedWalletBTCBip44Derivation)

            CheckedAddressBTCBip44 = CheckedWalletBTCBip44.address()
            print(CheckedAddressBTCBip44)

        if IsCheckBTCBip84 == "+":
            CheckedWalletBTCBip84 = Bip84.FromSeed(Seed, Bip84Coins.BITCOIN)
            CheckedWalletBTCBip84Step1 = (CheckedWalletBTCBip84.Purpose().Coin().Account(0)).Change(Bip44Changes.CHAIN_EXT)
            CheckedWalletBTCBip84Step2 = CheckedWalletBTCBip84Step1.AddressIndex(0)

            CheckedAddressBTCBip84 = CheckedWalletBTCBip84Step2.PublicKey().ToAddress()
            print(CheckedAddressBTCBip84)

    if IsCheckETH == "+":
        CheckedWalletETH = BIP44HDWallet(cryptocurrency = EthereumMainnet)
        CheckedWalletETH.from_mnemonic(mnemonic = Mnemonic, language = LanguageInMnemonic, passphrase = None)
        CheckedWalletETH.clean_derivation()
        CheckedWalletETHDerivation: BIP44Derivation = BIP44Derivation(cryptocurrency = EthereumMainnet, account = 0, change = False, address = 0)
        CheckedWalletETH.from_path(path=CheckedWalletETHDerivation)

        CheckedAddressETH = CheckedWalletETH.address()
        print(CheckedAddressETH)

```

(P. S. I used google translate)

> **Comments:**
> **username_3**: Why is the definition of IsCheckBTC not defined in your code snippet???  

---

### Answer by username_4 on 2023-09-04. Score: 0

Please you i get a php version of this code instead of Python.
I have a seed Phrase. I want the BTC address that correspond with Blockchain.
I want code in PHP so that i can modify to suit my project


---

