Bugfix: don't crash on keystores without description (#2967)

This commit is contained in:
zah 2021-10-07 19:30:34 +03:00 committed by GitHub
parent fabec894dd
commit 29ee9ec81e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -62,7 +62,8 @@ proc init*(t: typedesc[ValidatorPrivateItem], privateKey: ValidatorPrivKey,
keystore: Keystore): ValidatorPrivateItem = keystore: Keystore): ValidatorPrivateItem =
ValidatorPrivateItem( ValidatorPrivateItem(
privateKey: privateKey, privateKey: privateKey,
description: some(keystore.description[]), description: if keystore.description == nil: none(string)
else: some(keystore.description[]),
path: some(keystore.path), path: some(keystore.path),
uuid: some(keystore.uuid), uuid: some(keystore.uuid),
version: some(uint64(keystore.version)) version: some(uint64(keystore.version))
@ -284,7 +285,7 @@ proc loadKeystoreFile*(path: string): KsResult[Keystore] {.
except IOError as err: except IOError as err:
return err("Could not read keystore file") return err("Could not read keystore file")
except SerializationError as err: except SerializationError as err:
return err("Could not decode keystore file") return err("Could not decode keystore file: " & err.formatMsg(path))
proc loadSecretFile*(path: string): KsResult[KeystorePass] {. proc loadSecretFile*(path: string): KsResult[KeystorePass] {.
raises: [Defect].} = raises: [Defect].} =