Skip to content

Commit

Permalink
accounts/scwallet: replace strings.SplitN(arg, sep, 2) with strings.C…
Browse files Browse the repository at this point in the history
…ut(arg, sep) (ethereum#28446)
  • Loading branch information
gzliudan committed Jan 11, 2025
1 parent 7d289ff commit 01c650e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions accounts/scwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,16 +776,16 @@ func (w *Wallet) findAccountPath(account accounts.Account) (accounts.DerivationP
return nil, fmt.Errorf("scheme %s does not match wallet scheme %s", account.URL.Scheme, w.Hub.scheme)
}

parts := strings.SplitN(account.URL.Path, "/", 2)
if len(parts) != 2 {
url, path, found := strings.Cut(account.URL.Path, "/")
if !found {
return nil, fmt.Errorf("invalid URL format: %s", account.URL)
}

if parts[0] != fmt.Sprintf("%x", w.PublicKey[1:3]) {
if url != fmt.Sprintf("%x", w.PublicKey[1:3]) {
return nil, fmt.Errorf("URL %s is not for this wallet", account.URL)
}

return accounts.ParseDerivationPath(parts[1])
return accounts.ParseDerivationPath(path)
}

// Session represents a secured communication session with the wallet.
Expand Down

0 comments on commit 01c650e

Please sign in to comment.