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

./phrase.go:234:19: xprv.Child undefined (type *hdkeychain.ExtendedKey has no field or method Child) #1

Open
johndpope opened this issue Jun 8, 2021 · 2 comments

Comments

@johndpope
Copy link

./phrase.go:234:19: xprv.Child undefined (type *hdkeychain.ExtendedKey has no field or method Child)
./phrase.go:249:20: cha.Child undefined (type *hdkeychain.ExtendedKey has no field or method Child)

when I run go get
I get the above error.

@johndpope
Copy link
Author

I'm not sure if this is accurate

// Derive a key for a specific location in a BIP44 wallet
func deriveHDKey(xprv *hdkeychain.ExtendedKey, purpose uint32, coin uint32, account uint32, chain uint32, address uint32) (pubkey *hdkeychain.ExtendedKey, err error) {

	// Path: m/44H
	purp, err := xprv.Derive(hdkeychain.HardenedKeyStart + purpose)
	if err != nil {
		return
	}

	if purpose == 0 {
		// This is a bip32 path
		// Path: m/0H/[chain]
		var cha *hdkeychain.ExtendedKey
		cha, err = purp.Derive(chain)
		if err != nil {
			return
		}

		// Path: m/0H/[chain]/[child] (e.g. m/0H/0/0)
		pubkey, err = cha.Derive(address)
		return
	}

	// Coin number
	// Path: m/44H/60H
	co, err := purp.Derive(hdkeychain.HardenedKeyStart + coin)
	if err != nil {
		return
	}

	// Path: m/44H/60H/0H
	acc, err := co.Derive(hdkeychain.HardenedKeyStart + account)
	if err != nil {
		return
	}

	// Path: m/44H/60H/0H/0
	cha, err := acc.Derive(chain)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Path: m/44H/60H/0H/0/0
	pubkey, err = cha.Derive(address)
	if err != nil {
		fmt.Println(err)
		return
	}

	return
}

@mahmoud94ha
Copy link

what is the problem ? that am getting it ?

go run main.go
package command-line-arguments
imports github.com/tyler-smith/go-bip39
imports github.com/tyler-smith/go-bip39: import cycle not allowed

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

2 participants