keys: fix key validation #18

Merged
offbyn merged 1 commits from fix-key-validation into master 2 years ago

@ -541,19 +541,17 @@ importBtn.addEventListener('click', () => {
settingsForm.addEventListener('input', () => validKeys(privateKeyInput.value, pubKeyInput.value)); settingsForm.addEventListener('input', () => validKeys(privateKeyInput.value, pubKeyInput.value));
function validKeys(privatekey, pubkey) { function validKeys(privatekey, pubkey) {
if (pubkey && privatekey) { try {
try { if (getPublicKey(privatekey) === pubkey) {
if (getPublicKey(privatekey) === pubkey) { statusMessage.hidden = true;
statusMessage.hidden = true; statusMessage.textContent = 'public-key corresponds to private-key';
statusMessage.textContent = 'public-key corresponds to private-key'; importBtn.removeAttribute('disabled');
importBtn.removeAttribute('disabled'); return true;
return true; } else {
} else { statusMessage.textContent = 'private-key does not correspond to public-key!'
statusMessage.textContent = 'private-key does not correspond to public-key!'
}
} catch (e) {
statusMessage.textContent = `not a valid private-key: ${e.message || e}`;
} }
} catch (e) {
statusMessage.textContent = `not a valid private-key: ${e.message || e}`;
} }
statusMessage.hidden = false; statusMessage.hidden = false;
importBtn.setAttribute('disabled', true); importBtn.setAttribute('disabled', true);

Loading…
Cancel
Save