From b576ef4f2185d613e49d7d52a46d19477c875e21 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 26 Jul 2022 13:26:18 +0300 Subject: [PATCH] fix: scanAddressesWithAmount --- .../static/components/utxo-list/utxo-list.js | 8 ++++---- lnbits/extensions/watchonly/static/js/index.js | 11 ++++++++++- .../watchonly/templates/watchonly/index.html | 3 ++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lnbits/extensions/watchonly/static/components/utxo-list/utxo-list.js b/lnbits/extensions/watchonly/static/components/utxo-list/utxo-list.js index 64e48578..23776c79 100644 --- a/lnbits/extensions/watchonly/static/components/utxo-list/utxo-list.js +++ b/lnbits/extensions/watchonly/static/components/utxo-list/utxo-list.js @@ -102,22 +102,22 @@ async function utxoList(path) { return total }, applyUtxoSelectionMode: function () { + const mode = this.utxoSelectionMode const isSelectAll = mode === 'Select All' if (isSelectAll) { - this.utxos.data.forEach(u => (u.selected = true)) + this.utxos.forEach(u => (u.selected = true)) return } const payedAmount = this['payed-amount'] - const mode = this.payment.utxoSelectionMode - this.utxos.data.forEach(u => (u.selected = false)) + this.utxos.forEach(u => (u.selected = false)) const isManual = mode === 'Manual' if (isManual || !payedAmount) return const isSmallerFirst = mode === 'Smaller Inputs First' const isLargerFirst = mode === 'Larger Inputs First' - let selectedUtxos = this.utxos.data.slice() + let selectedUtxos = this.utxos.slice() if (isSmallerFirst || isLargerFirst) { const sortFn = isSmallerFirst ? (a, b) => a.amount - b.amount diff --git a/lnbits/extensions/watchonly/static/js/index.js b/lnbits/extensions/watchonly/static/js/index.js index dcc80cc0..ef0cac60 100644 --- a/lnbits/extensions/watchonly/static/js/index.js +++ b/lnbits/extensions/watchonly/static/js/index.js @@ -85,7 +85,8 @@ const watchOnly = async () => { showAddress: false, addressNote: '', - showPayment: false + showPayment: false, + fetchedUtxos: false } }, @@ -684,6 +685,7 @@ const watchOnly = async () => { this.utxos.total = 0 this.history = [] const addresses = this.addresses.filter(a => a.hasActivity) + console.log('### scanAddressWithAmount', this.addresses, addresses) await this.updateUtxosForAddresses(addresses) }, scanAddress: async function (addressData) { @@ -831,6 +833,13 @@ const watchOnly = async () => { }, showAddressDetails: function (addressData) { this.openQrCodeDialog(addressData) + }, + initUtxos: function (addresses) { + if (!this.fetchedUtxos && addresses.length) { + this.fetchedUtxos = true + this.addresses = addresses + this.scanAddressWithAmount() + } } }, created: async function () { diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index 77d99bba..448687bf 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -53,7 +53,7 @@ color="gray" class="btn-full" @click="showPayment = false" - >Discard PaymentBack @@ -85,6 +85,7 @@ :sats-denominated="config.data.sats_denominated" @scan:address="scanAddress" @show-address-details="showAddressDetails" + @update:addresses="initUtxos" :inkey="g.user.wallets[0].inkey" >