From 6c6f3fd3b78957579a0dccc5d5ce7d1c18eb1322 Mon Sep 17 00:00:00 2001 From: Anirudha Bose Date: Wed, 8 Jul 2020 16:37:07 +0530 Subject: [PATCH] hdkeychain: Remove duplicate ChildNum() method --- hdkeychain/extendedkey.go | 13 ++++--------- hdkeychain/extendedkey_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/hdkeychain/extendedkey.go b/hdkeychain/extendedkey.go index 48c0421..89727ac 100644 --- a/hdkeychain/extendedkey.go +++ b/hdkeychain/extendedkey.go @@ -198,14 +198,6 @@ func (k *ExtendedKey) ChainCode() []byte { return append([]byte{}, k.chainCode...) } -// ChildNum returns the index at which the child extended key was derived. -// -// Extended keys with ChildNum value between 0 and 2^31-1 are normal child -// keys, and those with a value between 2^31 and 2^32-1 are hardened keys. -func (k *ExtendedKey) ChildNum() uint32 { - return k.childNum -} - // Child returns a derived child extended key at the given index. When this // extended key is a private extended key (as determined by the IsPrivate // function), a private extended key will be derived. Otherwise, the derived @@ -350,7 +342,10 @@ func (k *ExtendedKey) Child(i uint32) (*ExtendedKey, error) { k.depth+1, i, isPrivate), nil } -// ChildIndex returns the child index used to derive the extended key. +// ChildNum returns the index at which the child extended key was derived. +// +// Extended keys with ChildNum value between 0 and 2^31-1 are normal child +// keys, and those with a value between 2^31 and 2^32-1 are hardened keys. func (k *ExtendedKey) ChildIndex() uint32 { return k.childNum } diff --git a/hdkeychain/extendedkey_test.go b/hdkeychain/extendedkey_test.go index 09c6f05..04c6673 100644 --- a/hdkeychain/extendedkey_test.go +++ b/hdkeychain/extendedkey_test.go @@ -623,10 +623,10 @@ func TestExtendedKeyAPI(t *testing.T) { continue } - childNum := key.ChildNum() - if childNum != test.childNum { - t.Errorf("ChildNum #%d (%s): want %d, got %d", i, - test.name, childNum, test.childNum) + childIndex := key.ChildIndex() + if childIndex != test.childNum { + t.Errorf("ChildIndex #%d (%s): want %d, got %d", i, + test.name, test.childNum, childIndex) continue }