diff --git a/lnbits/extensions/watchonly/static/js/index.js b/lnbits/extensions/watchonly/static/js/index.js index 0968e417..c00c254f 100644 --- a/lnbits/extensions/watchonly/static/js/index.js +++ b/lnbits/extensions/watchonly/static/js/index.js @@ -46,9 +46,13 @@ new Vue({ hww: { password: null, + showPassword: false, + mnemonic: null, + showMnemonic: false, authenticated: false, showPasswordDialog: false, showWipeDialog: false, + showRestoreDialog: false, showConsole: false, showSignedPsbt: false, sendingPsbt: false, @@ -742,6 +746,19 @@ new Vue({ }) } }, + hwwShowRestoreDialog: async function () { + try { + this.hww.showRestoreDialog = true + await this.serial.writer.write(COMMAND_WIPE + '\n') + } catch (error) { + this.$q.notify({ + type: 'warning', + message: 'Failed to connect to Hardware Wallet!', + caption: `${error}`, + timeout: 10000 + }) + } + }, hwwLogin: async function () { try { await this.serial.writer.write( @@ -757,6 +774,7 @@ new Vue({ } finally { this.hww.showPasswordDialog = false this.hww.password = null + this.hww.showPassword = false } }, handleLoginResponse: function (res = '') { @@ -887,6 +905,7 @@ new Vue({ }) } finally { this.hww.password = null + this.hww.showPassword = false } }, handleWipeResponse: function (res = '') { @@ -919,6 +938,29 @@ new Vue({ }) } }, + hwwRestore: async function () { + try { + await this.serial.writer.write( + COMMAND_RESTORE + ' ' + this.hww.mnemonic + '\n' + ) + await this.serial.writer.write( + COMMAND_PASSWORD + ' ' + this.hww.password + '\n' + ) + } catch (error) { + this.$q.notify({ + type: 'warning', + message: 'Failed to restore from seed!', + caption: `${error}`, + timeout: 10000 + }) + } finally { + this.hww.showRestoreDialog = false + this.hww.mnemonic = null + this.hww.showMnemonic = false + this.hww.password = null + this.hww.showPassword = false + } + }, //################### UTXOs ################### scanAllAddresses: async function () { await this.refreshAddresses() diff --git a/lnbits/extensions/watchonly/static/js/utils.js b/lnbits/extensions/watchonly/static/js/utils.js index 811a7b3c..3a606fe4 100644 --- a/lnbits/extensions/watchonly/static/js/utils.js +++ b/lnbits/extensions/watchonly/static/js/utils.js @@ -6,6 +6,7 @@ const COMMAND_SIGN_PSBT = '/sign' const COMMAND_HELP = '/help' const COMMAND_WIPE = '/wipe' const COMMAND_SEED = '/seed' +const COMMAND_RESTORE = '/restore' const blockTimeToDate = blockTime => blockTime ? moment(blockTime * 1000).format('LLL') : '' diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index e428c2d7..d44ada38 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -1175,7 +1175,11 @@ > - + Restore - Enter password for Hardware Wallet + Enter password for Hardware Wallet (8 numbers/letters) - Enter new password for Hardware Wallet + Enter new password for Hardware Wallet (8 numbers/letters) + + + + + For test purposes only. Do not enter word list with real funds!!! + +


+ Enter new word list separated by space + + + +
+ Enter new password (8 numbers/letters) + + + +

+ + For test purposes only. Do not enter word list with real funds. + + +
+ Restore + Cancel +
+
+
+
{% endraw %}