Skip to content

Commit 5a32f04

Browse files
committed
accounts/scwallet: replace strings.SplitN(arg, sep, 2) with strings.Cut(arg, sep) (ethereum#28446)
1 parent 6f5fb53 commit 5a32f04

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

accounts/scwallet/wallet.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,16 +776,16 @@ func (w *Wallet) findAccountPath(account accounts.Account) (accounts.DerivationP
776776
return nil, fmt.Errorf("scheme %s does not match wallet scheme %s", account.URL.Scheme, w.Hub.scheme)
777777
}
778778

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

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

788-
return accounts.ParseDerivationPath(parts[1])
788+
return accounts.ParseDerivationPath(path)
789789
}
790790

791791
// Session represents a secured communication session with the wallet.

0 commit comments

Comments
 (0)