Skip to content

Commit

Permalink
waddrmgr: use Derive() instead of DeriveNonStandard()
Browse files Browse the repository at this point in the history
  • Loading branch information
roylee17 committed Sep 17, 2022
1 parent 1f05a98 commit 78b8743
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions waddrmgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,15 +1467,15 @@ 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 {
return nil, err
}

// 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 {
Expand All @@ -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,
)
}
Expand All @@ -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
}

Expand Down
12 changes: 6 additions & 6 deletions waddrmgr/scoped_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down

0 comments on commit 78b8743

Please sign in to comment.