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

fix leading zero #159

Closed
wants to merge 1 commit into from
Closed

fix leading zero #159

wants to merge 1 commit into from

Conversation

klim0v
Copy link

@klim0v klim0v commented Mar 3, 2020

it was a mistake on the m/44H/60H/0H path
For example, mnemonic := "real town addict extend shoot name disagree vital turn live can tip"
got c64f0b3e510d03adef3f057d1814bdc8a7f904caafa6928550fc10670dcff031
wanted c29cd818232f40614691a58c9afcbd5518b539cb135d73b1d9e26d5f5f5dcbbe (https://iancoleman.io/bip39/)

        // Generate a Bip32 HD wallet for the mnemonic and a user supplied password
	seed := bip39.NewSeed(mnemonic, "")

	// Generate a new master node using the seed.
	masterKey, err := hdkeychain.NewMaster(seed, &chaincfg.MainNetParams)
	if err != nil {
		return nil, nil, err
	}

	// This gives the path: m/44H
	acc44H, err := masterKey.Child(hdkeychain.HardenedKeyStart + 44)
	if err != nil {
		return nil, nil, err
	}

	// This gives the path: m/44H/60H
	acc44H60H, err := acc44H.Child(hdkeychain.HardenedKeyStart + 60)
	if err != nil {
		return nil, nil, err
	}

	// This gives the path: m/44H/60H/0H
	acc44H60H0H, err := acc44H60H.Child(hdkeychain.HardenedKeyStart + 0)
	if err != nil {
		return nil, nil, err
	}

	// This gives the path: m/44H/60H/0H/0
	acc44H60H0H0, err := acc44H60H0H.Child(0)
	if err != nil {
		return nil, nil, err
	}

	// This gives the path: m/44H/60H/0H/0/0
	acc44H60H0H00, err := acc44H60H0H0.Child(0)
	if err != nil {
		return nil, nil, err
	}

	btcecPrivKey, err := acc44H60H0H00.ECPrivKey()
	if err != nil {
		return nil, nil, err
	}

	privateKey := btcecPrivKey.ToECDSA()

@jakesylvestre
Copy link

jakesylvestre commented Mar 11, 2020

Can you add a description here?

@klim0v
Copy link
Author

klim0v commented Mar 11, 2020

Can you add a description here?

Done

Copy link
Member

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you added a bunch of examples to the github conversation. That is helpful, but could you add the description to the git commit messages? The git repo should be the main source of info rather than the associated github stuff?

Also, could you please add some test cases for this to the test code? For key related things it is extra important to have tests in the repo.

@klim0v klim0v closed this Mar 13, 2020
@klim0v klim0v deleted the patch-1 branch March 13, 2020 15:01
@klim0v
Copy link
Author

klim0v commented Mar 13, 2020

#161

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

Successfully merging this pull request may close these issues.

None yet

3 participants