keys/hd/address.go
func DerivePublicKeyForPath(pubKeyBytes []byte, chainCode []byte, path string) []byte {
	data := pubKeyBytes
	parts := strings.Split(path, "/")
	for _, part := range parts {
		prime := part[len(part)-1:] == "'"
		if prime {
			panic(errors.New("cannot do a prime derivation from public key"))
		}
		i, err := strconv.Atoi(part)
		if err != nil {
			panic(err)
		}
		if i < 0 {
			panic(errors.New("index too large."))
		}
		data, chainCode = DerivePublicKey(data, chainCode, uint32(i))
		//printKeyInfo(nil, data, chainCode)
	}
	return data
}
func DerivePublicKeyForPath(pubKeyBytes []byte, chainCode []byte, path string) []byte {
	data := pubKeyBytes
	parts := strings.Split(path, "/")
	for _, part := range parts {
		prime := part[len(part)-1:] == "'"
		if prime {
			panic(errors.New("cannot do a prime derivation from public key"))
		}
		i, err := strconv.Atoi(part)
		if err != nil {
			panic(err)
		}
		if i < 0 {
			panic(errors.New("index too large."))
		}
		data, chainCode = DerivePublicKey(data, chainCode, uint32(i))
		//printKeyInfo(nil, data, chainCode)
	}
	return data
}
func DerivePublicKeyForPath ( pubKeyBytes [ ] byte , chainCode [ ] byte , path string ) [ ] byte { data := pubKeyBytes parts := strings . Split ( path , " " ) for _ , part := range parts { prime := part [ len ( part ) - 1 : ] == " " if prime { panic ( errors . New ( " " ) ) } i , err := strconv . Atoi ( part ) if err != nil { panic ( err ) } if i < 0 { panic ( errors . New ( " " ) ) } data , chainCode = DerivePublicKey ( data , chainCode , uint32 ( i ) ) //printKeyInfo(nil, data, chainCode) } return data }
// DerivePublicKeyForPath derives the public key by following the path from pubKeyBytes
// using the given chainCode.
DerivePublicKeyForPath derives the public key by following the path from pubKeyBytes using the given chainCode .