meherett / python-hdwallet

Python-based library for the implementation of a hierarchical deterministic wallet generator for more than 140+ multiple cryptocurrencies.
https://hdwallet.readthedocs.io
MIT License
458 stars 150 forks source link

p2sh address different from those generated by the Ian Coleman bip39 tools and other tools #5

Closed loupiote closed 3 years ago

loupiote commented 3 years ago

mnemonic: "all all all all all all all all all all all all" no passphrase

derivation path: "m/49'/0'/0'/1/0 correct address: 3Jdnbtqg3f8YberUzEirLLAumsp7RYt4Kw

incorrect address returned by HDWallet: 3K7n6sivDyYPgkkmBcQMWhLxJvH2AuaHVy

Note: I confirmed the correct address also with bip_utils

Also, i think that wallet.address() should still be defined as an alias to wallet.p2pkh_address(), to keep old scripts compatible (and also the example of this page still uses address() )

meherett commented 3 years ago

@loupiote It works correctly. For BIP49 implementation the address is also P2WPKH nested in P2SH not P2SH.

P2WPKH_IN_P2SH -> 3Jdnbtqg3f8YberUzEirLLAumsp7RYt4Kw P2SH -> 3K7n6sivDyYPgkkmBcQMWhLxJvH2AuaHVy

You can use hdwallet.BIP49HDWallet class. Thanks :)

loupiote commented 3 years ago

This is the code i'm using. Can you correct it to show me the code that provides the correct address? thanks in advance!!

from hdwallet import HDWallet

wallet = HDWallet(symbol=BTC) wallet.from_mnemonic(mnemonic="all all all all all all all all all all all all") path = "m/49'/0'/0'/1/0" wallet.from_path(path) addr = wallet.p2sh_address()

meherett commented 3 years ago

wallet = HDWallet(symbol=BTC) wallet.from_mnemonic(mnemonic="all all all all all all all all all all all all") path = "m/49'/0'/0'/1/0" wallet.from_path(path) addr = wallet.p2wpkh_in_p2sh_address()

Thanks!

loupiote commented 2 years ago

How do you get a BIP-84 native segwit address that start with "bc1q" ? (e.g. path = "m/84'/0'/0'/1/0")