From ae479ee0d011c95a845e7fbc56805b85beb01867 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Mon, 1 Aug 2022 14:52:11 +0300 Subject: [PATCH] feat: show hardware device Xpub option --- .../components/wallet-list/wallet-list.html | 53 ++++++++++++-- .../components/wallet-list/wallet-list.js | 69 ++++++++++++++++++- .../extensions/watchonly/static/js/index.js | 2 +- .../watchonly/templates/watchonly/index.html | 1 + 4 files changed, 118 insertions(+), 7 deletions(-) diff --git a/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.html b/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.html index 950bceeb..3745711d 100644 --- a/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.html +++ b/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.html @@ -3,9 +3,32 @@
- Add Wallet Account - + + + + + New Account + Enter account Xpub or Descriptor + + + + + From Hardware Device + + Get Xpub from a Hardware Device + + + +
@@ -158,8 +181,8 @@ type="text" label="Title" > - + + +
Add Watch-Only Account w.id === walletId) || {} wallet.address_no = addressData.addressIndex this.$emit('new-receive-address', addressData) + }, + showAddAccountDialog: function() { + this.formDialog.show = true + this.formDialog.useSerialPort = false + }, + getXpubFromDevice: async function () { + this.handleAddressTypeChanged('wpkh') + try { + if (!this.serialSignerRef.isConnected()) { + const portOpen = await this.serialSignerRef.openSerialPort() + if (!portOpen) return + } + if (!this.serialSignerRef.isAuthenticated()) { + await this.serialSignerRef.hwwShowPasswordDialog() + const authenticated = await this.serialSignerRef.isAuthenticating() + if (!authenticated) return + } + this.formDialog.show = true + this.formDialog.useSerialPort = true + } catch (error) { + this.$q.notify({ + type: 'warning', + message: 'Cannot fetch Xpub!', + caption: `${error}`, + timeout: 10000 + }) + } + }, + handleAddressTypeChanged: function (value) { + const addressType = + this.addressTypeOptions.find(t => t.value === value) || {} + this.formDialog.data.accountPath = addressType.path } }, created: async function () { diff --git a/lnbits/extensions/watchonly/static/js/index.js b/lnbits/extensions/watchonly/static/js/index.js index 59fec402..536fab8f 100644 --- a/lnbits/extensions/watchonly/static/js/index.js +++ b/lnbits/extensions/watchonly/static/js/index.js @@ -329,7 +329,7 @@ const watchOnly = async () => { hostname: this.mempoolHostname }) const fn = async () => { - if (!accounts.find(w => (w.id === addrData.wallet))) return [] + if (!accounts.find(w => w.id === addrData.wallet)) return [] return addressesAPI.getAddressTxs({ address: addrData.address }) diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index 08ba6d98..ec605e18 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -23,6 +23,7 @@ :sats-denominated="config.sats_denominated" :network="config.network" :addresses="addresses" + :serial-signer-ref="$refs.serialSigner" @accounts-update="updateAccounts" @new-receive-address="showAddressDetails" >