From 8ab09fda40b4981aa98b8f8476a54b583c11bc58 Mon Sep 17 00:00:00 2001 From: OFF0 Date: Thu, 8 Dec 2022 23:12:50 +0100 Subject: [PATCH] settings: pasting private key should update pubkey If the user pastes a private-key and the pubkey input is empty, it should be ok to generate and autofill the pubkey field without confusing the user. There might be circumstances where it is preferred to see an error if the pubkey does not correspond with the private key. Added an on paste event listener that tries to generate and auto- fill the pubkey (if empty). --- src/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.js b/src/main.js index 273f3e4..488935d 100644 --- a/src/main.js +++ b/src/main.js @@ -579,6 +579,13 @@ importBtn.addEventListener('click', () => { }); settingsForm.addEventListener('input', () => validKeys(privateKeyInput.value, pubKeyInput.value)); +privateKeyInput.addEventListener('paste', (event) => { + if (!pubKeyInput.value && event.clipboardData) { + try { + pubKeyInput.value = getPublicKey(event.clipboardData.getData('text')); + } catch(err) {} // ignore as the error will be shown by validKeys later on input + } +}); function validKeys(privatekey, pubkey) { try {