From 6a4266526dcfff7be504e4fd88715bea3c5c0f44 Mon Sep 17 00:00:00 2001 From: OFF0 Date: Tue, 6 Dec 2022 20:57:20 +0100 Subject: [PATCH] keys: fix key validation Pub and private key settings only showed errors if both values were truthy, but it did not validate if one input was falsy, in which case it only showed the last error. Removed truthy check as it is not needed. --- src/main.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main.js b/src/main.js index e3f0146..d4bedaa 100644 --- a/src/main.js +++ b/src/main.js @@ -541,19 +541,17 @@ importBtn.addEventListener('click', () => { settingsForm.addEventListener('input', () => validKeys(privateKeyInput.value, pubKeyInput.value)); function validKeys(privatekey, pubkey) { - if (pubkey && privatekey) { - try { - if (getPublicKey(privatekey) === pubkey) { - statusMessage.hidden = true; - statusMessage.textContent = 'public-key corresponds to private-key'; - importBtn.removeAttribute('disabled'); - return true; - } else { - statusMessage.textContent = 'private-key does not correspond to public-key!' - } - } catch (e) { - statusMessage.textContent = `not a valid private-key: ${e.message || e}`; + try { + if (getPublicKey(privatekey) === pubkey) { + statusMessage.hidden = true; + statusMessage.textContent = 'public-key corresponds to private-key'; + importBtn.removeAttribute('disabled'); + return true; + } else { + statusMessage.textContent = 'private-key does not correspond to public-key!' } + } catch (e) { + statusMessage.textContent = `not a valid private-key: ${e.message || e}`; } statusMessage.hidden = false; importBtn.setAttribute('disabled', true); -- 2.46.2