Skip to content

Commit 216f11b

Browse files
committed
- bug with original pathAppendix fixed
1 parent b82e347 commit 216f11b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sources/Web3Core/KeystoreManager/BIP32Keystore.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public class BIP32Keystore: AbstractKeystore {
162162

163163
public func createNewCustomChildAccount(password: String, path: String) throws {
164164
guard let decryptedRootNode = try getPrefixNodeData(password),
165-
let keystoreParams = keystoreParams else {
165+
let keystoreParams else {
166166
throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore")
167167
}
168168
guard let rootNode = HDNode(decryptedRootNode) else {
@@ -179,17 +179,17 @@ public class BIP32Keystore: AbstractKeystore {
179179
throw AbstractKeystoreError.encryptionError("out of bounds")
180180
}
181181

182-
guard var pathAppendix = pathAppendix else {
182+
guard let modifiedAppendix = pathAppendix else {
183183
throw AbstractKeystoreError.encryptionError("Derivation depth mismatch")
184184
}
185-
if pathAppendix.hasPrefix("/") {
186-
pathAppendix = pathAppendix.trimmingCharacters(in: CharacterSet.init(charactersIn: "/"))
185+
if modifiedAppendix.hasPrefix("/") {
186+
pathAppendix = modifiedAppendix.trimmingCharacters(in: CharacterSet.init(charactersIn: "/"))
187187
}
188188
} else if path.hasPrefix("/") {
189189
pathAppendix = path.trimmingCharacters(in: CharacterSet.init(charactersIn: "/"))
190190
}
191191

192-
guard let pathAppendix = pathAppendix,
192+
guard let pathAppendix,
193193
rootNode.depth == prefixPath.components(separatedBy: "/").count - 1 else {
194194
throw AbstractKeystoreError.encryptionError("Derivation depth mismatch")
195195
}

0 commit comments

Comments
 (0)