Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Litecoin (LTC) parsing #416

Open
ravi-ojha opened this issue Feb 8, 2024 · 0 comments
Open

Issue with Litecoin (LTC) parsing #416

ravi-ojha opened this issue Feb 8, 2024 · 0 comments

Comments

@ravi-ojha
Copy link

What I was trying to do?

Generate addresses for Account Extended Public Key (specifically bip84_pub

What's the error?

It returns None when hparse function is called.

What's the resolution?

The reason hparse returns None is due to this check. if data is None or prefix is None or not data.startswith(prefix).
The prefix comes out as None. The value for bip84_pub_prefix is not set correctly for LTC. That's why the prefix is None. If you remove this condition check, it will generate the correct LTC addresses nevertheless.

I think the real solution is to update symbol/ltc.py and pass extra kwargs bip84_prv_prefix_hex="04b2430c", bip84_pub_prefix_hex="04B24746", in create_bitcoinish_network function.

Here's my full script if you want to reproduce it.

Dependencies: pycoin==0.92.20230326, tqdm

from pycoin.networks.registry import network_for_netcode
from tqdm import tqdm

# Your BIP32 Account extended public key
ZPUB = "zpub6qXw6cLRkWUQVGgNU1qXhSmGY9fcmvaosAj6NbbMkBZSD1xUhGVyQvyRPEuCizbEn8arDymyAQZzyxRdcjwL9YszG3fZC2cPUg6uiB8ZvuS"  # noqa


network = network_for_netcode("LTC")


def derive_bech32_address(zpub, derivation_path):
    k = network.parse.bip84_pub(zpub)  # k will be None because unless that condition explained above is removed
    a = k.subkey_for_path(derivation_path)
    bech32_add = network.address.for_p2pkh_wit(a.hash160())
    return bech32_add


def generate_ltc_addresses():
    addresses = []
    COUNT = 100

    for i in tqdm(range(COUNT)):
        address = derive_bech32_address(ZPUB, f"0/{i}")
        addresses.append(address)

    with open("ltc_addresses.txt", "w") as f:
        for address in addresses:
            f.write(f"{address}\n")


if __name__ == "__main__":
    generate_ltc_addresses()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant