From 10470208fb98406f8623c71964a9b79d05a4093b Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Thu, 15 Sep 2022 22:20:02 -0700 Subject: [PATCH] waddrmgr: use Derive() instead of DeriveNonStandard() --- waddrmgr/manager.go | 10 +++++----- waddrmgr/scoped_manager.go | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/waddrmgr/manager.go b/waddrmgr/manager.go index 7682425..a7c7e47 100644 --- a/waddrmgr/manager.go +++ b/waddrmgr/manager.go @@ -1467,7 +1467,7 @@ func deriveCoinTypeKey(masterNode *hdkeychain.ExtendedKey, // The branch is 0 for external addresses and 1 for internal addresses. // Derive the purpose key as a child of the master node. - purpose, err := masterNode.DeriveNonStandard( // nolint:staticcheck + purpose, err := masterNode.Derive( scope.Purpose + hdkeychain.HardenedKeyStart, ) if err != nil { @@ -1475,7 +1475,7 @@ func deriveCoinTypeKey(masterNode *hdkeychain.ExtendedKey, } // Derive the coin type key as a child of the purpose key. - coinTypeKey, err := purpose.DeriveNonStandard( // nolint:staticcheck + coinTypeKey, err := purpose.Derive( scope.Coin + hdkeychain.HardenedKeyStart, ) if err != nil { @@ -1501,7 +1501,7 @@ func deriveAccountKey(coinTypeKey *hdkeychain.ExtendedKey, } // Derive the account key as a child of the coin type key. - return coinTypeKey.DeriveNonStandard( // nolint:staticcheck + return coinTypeKey.Derive( account + hdkeychain.HardenedKeyStart, ) } @@ -1519,12 +1519,12 @@ func deriveAccountKey(coinTypeKey *hdkeychain.ExtendedKey, // The branch is 0 for external addresses and 1 for internal addresses. func checkBranchKeys(acctKey *hdkeychain.ExtendedKey) error { // Derive the external branch as the first child of the account key. - if _, err := acctKey.DeriveNonStandard(ExternalBranch); err != nil { // nolint:staticcheck + if _, err := acctKey.Derive(ExternalBranch); err != nil { return err } // Derive the internal branch as the second child of the account key. - _, err := acctKey.DeriveNonStandard(InternalBranch) // nolint:staticcheck + _, err := acctKey.Derive(InternalBranch) return err } diff --git a/waddrmgr/scoped_manager.go b/waddrmgr/scoped_manager.go index 83c3e99..a2f37fe 100644 --- a/waddrmgr/scoped_manager.go +++ b/waddrmgr/scoped_manager.go @@ -345,14 +345,14 @@ func (s *ScopedKeyManager) deriveKey(acctInfo *accountInfo, branch, } // Derive and return the key. - branchKey, err := acctKey.DeriveNonStandard(branch) // nolint:staticcheck + branchKey, err := acctKey.Derive(branch) if err != nil { str := fmt.Sprintf("failed to derive extended key branch %d", branch) return nil, managerError(ErrKeyChain, str, err) } - addressKey, err := branchKey.DeriveNonStandard(index) // nolint:staticcheck + addressKey, err := branchKey.Derive(index) // Zero branch key after it's used. branchKey.Zero() @@ -1013,7 +1013,7 @@ func (s *ScopedKeyManager) nextAddresses(ns walletdb.ReadWriteBucket, } // Derive the appropriate branch key and ensure it is zeroed when done. - branchKey, err := acctKey.DeriveNonStandard(branchNum) // nolint:staticcheck + branchKey, err := acctKey.Derive(branchNum) if err != nil { str := fmt.Sprintf("failed to derive extended key branch %d", branchNum) @@ -1030,7 +1030,7 @@ func (s *ScopedKeyManager) nextAddresses(ns walletdb.ReadWriteBucket, var nextKey *hdkeychain.ExtendedKey for { // Derive the next child in the external chain branch. - key, err := branchKey.DeriveNonStandard(nextIndex) // nolint:staticcheck + key, err := branchKey.Derive(nextIndex) if err != nil { // When this particular child is invalid, skip to the // next index. @@ -1215,7 +1215,7 @@ func (s *ScopedKeyManager) extendAddresses(ns walletdb.ReadWriteBucket, } // Derive the appropriate branch key and ensure it is zeroed when done. - branchKey, err := acctKey.DeriveNonStandard(branchNum) // nolint:staticcheck + branchKey, err := acctKey.Derive(branchNum) if err != nil { str := fmt.Sprintf("failed to derive extended key branch %d", branchNum) @@ -1234,7 +1234,7 @@ func (s *ScopedKeyManager) extendAddresses(ns walletdb.ReadWriteBucket, var nextKey *hdkeychain.ExtendedKey for { // Derive the next child in the external chain branch. - key, err := branchKey.DeriveNonStandard(nextIndex) // nolint:staticcheck + key, err := branchKey.Derive(nextIndex) if err != nil { // When this particular child is invalid, skip to the // next index. -- 2.45.3