From 123b3655e260401820ba6415bbb70b1121ac893a 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. --- src/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.js b/src/main.js index 273f3e4..9cf3fc6 100644 --- a/src/main.js +++ b/src/main.js @@ -605,6 +605,12 @@ privateTgl.addEventListener('click', () => { privateKeyInput.value = localStorage.getItem('private_key'); pubKeyInput.value = localStorage.getItem('pub_key'); +privateKeyInput.addEventListener('paste', (event) => { + if (!pubKeyInput.value && event.clipboardData) { + pubKeyInput.value = getPublicKey(event.clipboardData.getData('text')); + } +}); + document.body.addEventListener('click', (e) => { const container = e.target.closest('[data-append]'); if (container) {