diff --git a/lnbits/extensions/watchonly/static/components/address-list/address-list.js b/lnbits/extensions/watchonly/static/components/address-list/address-list.js
index 6614c6e2..010a97b6 100644
--- a/lnbits/extensions/watchonly/static/components/address-list/address-list.js
+++ b/lnbits/extensions/watchonly/static/components/address-list/address-list.js
@@ -5,6 +5,14 @@ async function addressList(path) {
template,
props: ['accounts', 'mempool_endpoint', 'inkey'],
+ watch: {
+ immediate: true,
+ accounts(newVal, oldVal) {
+ if ((newVal || []).length !== (oldVal || []).length) {
+ this.refreshAddresses() // todo await
+ }
+ }
+ },
data: function () {
return {
addresses: [],
@@ -65,15 +73,7 @@ async function addressList(path) {
}
}
},
- watch: {
- immediate: true,
- accounts(newVal, oldVal) {
- if ((newVal || []).length !== (oldVal || []).length) {
- console.log('### refreshAddresses')
- this.refreshAddresses() // todo await
- }
- }
- },
+
methods: {
satBtc(val, showUnit = true) {
@@ -95,8 +95,6 @@ async function addressList(path) {
return r
}, {})
- console.log('### walletsLimit', walletsLimit)
- console.log('### this.addresses', this.addresses)
const fAddresses = this.addresses.filter(
a =>
(includeChangeAddrs || !a.isChange) &&
@@ -106,7 +104,6 @@ async function addressList(path) {
!(excludeNoAmount && a.amount === 0) &&
(!selectedWalletId || a.wallet === selectedWalletId)
)
- console.log('### fAddresses', fAddresses)
return fAddresses
},
getAddressesForWallet: async function (walletId) {
@@ -128,7 +125,6 @@ async function addressList(path) {
return []
},
refreshAddresses: async function () {
- console.log('### refreshAddresses, this.accounts', this.accounts)
if (!this.accounts) return
this.addresses = []
for (const {id, type} of this.accounts) {
@@ -151,7 +147,6 @@ async function addressList(path) {
})
this.addresses.push(...uniqueAddresses)
}
- console.log('### refreshAddresses, this.addresse', this.addresses)
this.$emit('update:addresses', this.addresses)
},
scanAddress: async function (addressData) {
@@ -164,6 +159,7 @@ async function addressList(path) {
created: async function () {
await this.refreshAddresses()
+ // this.$emit('update:addresses', this.addresses)
}
})
}
diff --git a/lnbits/extensions/watchonly/static/components/history/history.html b/lnbits/extensions/watchonly/static/components/history/history.html
new file mode 100644
index 00000000..87b71583
--- /dev/null
+++ b/lnbits/extensions/watchonly/static/components/history/history.html
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Export to CSV
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{props.row.confirmed ? 'Sent' : 'Sending...'}}
+
+
+ {{props.row.confirmed ? 'Received' : 'Receiving...'}}
+
+
+
+ {{satBtc(props.row.totalAmount || props.row.amount)}}
+
+
+
+ {{props.row.address}}
+
+ ...
+
+
+ {{ props.row.date }}
+
+
+
+
+
+
UTXOs
+
{{satBtc(props.row.amount)}}
+
{{props.row.address}}
+
+
+
+
{{satBtc(s.amount)}}
+
{{s.address}}
+
+
+
Fee
+
{{satBtc(props.row.fee)}}
+
+
+
Block Height
+
{{props.row.height}}
+
+
+
+
+
+
diff --git a/lnbits/extensions/watchonly/static/components/history/history.js b/lnbits/extensions/watchonly/static/components/history/history.js
new file mode 100644
index 00000000..29bdda30
--- /dev/null
+++ b/lnbits/extensions/watchonly/static/components/history/history.js
@@ -0,0 +1,95 @@
+async function history(path) {
+ const template = await loadTemplateAsync(path)
+ Vue.component('history', {
+ name: 'history',
+ template,
+
+ props: ['history', 'mempool_endpoint'],
+ data: function () {
+ return {
+ historyTable: {
+ columns: [
+ {
+ name: 'expand',
+ align: 'left',
+ label: ''
+ },
+ {
+ name: 'status',
+ align: 'left',
+ label: 'Status'
+ },
+ {
+ name: 'amount',
+ align: 'left',
+ label: 'Amount',
+ field: 'amount',
+ sortable: true
+ },
+ {
+ name: 'address',
+ align: 'left',
+ label: 'Address',
+ field: 'address',
+ sortable: true
+ },
+ {
+ name: 'date',
+ align: 'left',
+ label: 'Date',
+ field: 'date',
+ sortable: true
+ }
+ ],
+ exportColums: [
+ {
+ label: 'Action',
+ field: 'action'
+ },
+ {
+ label: 'Date&Time',
+ field: 'date'
+ },
+ {
+ label: 'Amount',
+ field: 'amount'
+ },
+ {
+ label: 'Fee',
+ field: 'fee'
+ },
+ {
+ label: 'Transaction Id',
+ field: 'txId'
+ }
+ ],
+ pagination: {
+ rowsPerPage: 0
+ },
+ filter: ''
+ }
+ }
+ },
+
+ methods: {
+ satBtc(val, showUnit = true) {
+ return satOrBtc(val, showUnit, this['sats_denominated'])
+ },
+ getFilteredAddressesHistory: function () {
+ return this.history.filter(a => (!a.isChange || a.sent) && !a.isSubItem)
+ },
+ exportHistoryToCSV: function () {
+ const history = this.getFilteredAddressesHistory().map(a => ({
+ ...a,
+ action: a.sent ? 'Sent' : 'Received'
+ }))
+ LNbits.utils.exportCSV(
+ this.historyTable.exportColums,
+ history,
+ 'address-history'
+ )
+ }
+ },
+ created: async function () {}
+ })
+}
diff --git a/lnbits/extensions/watchonly/static/js/index.js b/lnbits/extensions/watchonly/static/js/index.js
index 66ecd3c1..611abbd6 100644
--- a/lnbits/extensions/watchonly/static/js/index.js
+++ b/lnbits/extensions/watchonly/static/js/index.js
@@ -4,6 +4,7 @@ const watchOnly = async () => {
await walletConfig('static/components/wallet-config/wallet-config.html')
await walletList('static/components/wallet-list/wallet-list.html')
await addressList('static/components/address-list/address-list.html')
+ await history('static/components/history/history.html')
Vue.filter('reverse', function (value) {
// slice to make a copy of array, then reverse the copy
@@ -158,20 +159,7 @@ const watchOnly = async () => {
})
return addressHistory
},
- getFilteredAddressesHistory: function () {
- return this.history.filter(a => (!a.isChange || a.sent) && !a.isSubItem)
- },
- exportHistoryToCSV: function () {
- const history = this.getFilteredAddressesHistory().map(a => ({
- ...a,
- action: a.sent ? 'Sent' : 'Received'
- }))
- LNbits.utils.exportCSV(
- this.historyTable.exportColums,
- history,
- 'address-history'
- )
- },
+
markSameTxAddressHistory: function () {
this.history
.filter(s => s.sent)
@@ -807,11 +795,12 @@ const watchOnly = async () => {
this.utxos.data = []
this.utxos.total = 0
this.history = []
+ console.log('### scanAddressWithAmount1', this.addresses)
const addresses = this.addresses.filter(a => a.hasActivity)
+ console.log('### scanAddressWithAmount2', addresses)
await this.updateUtxosForAddresses(addresses)
},
scanAddress: async function (addressData) {
- console.log('### scanAddress', addressData)
this.updateUtxosForAddresses([addressData])
this.$q.notify({
type: 'positive',
@@ -830,7 +819,8 @@ const watchOnly = async () => {
h => h.address !== addrData.address
)
- // add new entrie
+ console.log('### addressHistory', addressHistory)
+ // add new entries
this.history.push(...addressHistory)
this.history.sort((a, b) => (!a.height ? -1 : b.height - a.height))
this.markSameTxAddressHistory()
@@ -975,7 +965,6 @@ const watchOnly = async () => {
//################### OTHER ###################
openQrCodeDialog: function (addressData) {
- console.log('### addressData', addressData)
this.currentAddress = addressData
this.addressNote = addressData.note || ''
this.showAddress = true
@@ -1005,16 +994,16 @@ const watchOnly = async () => {
}
},
showAddressDetails: function (addressData) {
- console.log('### showAddressDetails addressData', addressData)
this.openQrCodeDialog(addressData)
},
- handleAddressesUpdated: function (addresses) {
+ handleAddressesUpdated: async function (addresses) {
this.addresses = addresses
+ await this.scanAddressWithAmount()
}
},
created: async function () {
if (this.g.user.wallets.length) {
- // await this.refreshAddressesxxx() todo: done when
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Export to CSV
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{props.row.confirmed ? 'Sent' : 'Sending...'}}
-
-
- {{props.row.confirmed ? 'Received' : 'Receiving...'}}
-
-
-
-
- {{satBtc(props.row.totalAmount || props.row.amount)}}
-
-
-
-
- {{props.row.address}}
-
- ...
-
-
- {{ props.row.date }}
-
-
-
-
-
-
UTXOs
-
- {{satBtc(props.row.amount)}}
-
-
{{props.row.address}}
-
-
-
-
{{satBtc(s.amount)}}
-
{{s.address}}
-
-
-
Fee
-
{{satBtc(props.row.fee)}}
-
-
-
Block Height
-
{{props.row.height}}
-
-
-
-
-
+
@@ -1277,5 +1132,6 @@
+
{% endblock %}