fix: stop scanning when network changed

This commit is contained in:
Vlad Stan 2022-08-01 13:21:14 +03:00
parent 6150b767e4
commit 5697bd3b31
3 changed files with 26 additions and 25 deletions

View file

@ -50,7 +50,6 @@ async function walletList(path) {
watch: { watch: {
immediate: true, immediate: true,
async network(newNet, oldNet) { async network(newNet, oldNet) {
console.log('### newNet, oldNet', newNet, oldNet)
if (newNet !== oldNet) { if (newNet !== oldNet) {
await this.refreshWalletAccounts() await this.refreshWalletAccounts()
} }
@ -131,6 +130,7 @@ async function walletList(path) {
return [] return []
}, },
refreshWalletAccounts: async function () { refreshWalletAccounts: async function () {
this.walletAccounts = []
const wallets = await this.getWatchOnlyWallets() const wallets = await this.getWatchOnlyWallets()
this.walletAccounts = wallets.map(w => mapWalletAccount(w)) this.walletAccounts = wallets.map(w => mapWalletAccount(w))
this.$emit('accounts-update', this.walletAccounts) this.$emit('accounts-update', this.walletAccounts)

View file

@ -164,7 +164,6 @@ const watchOnly = async () => {
//################### PSBT ################### //################### PSBT ###################
updateSignedPsbt: async function (psbtBase64) { updateSignedPsbt: async function (psbtBase64) {
console.log('### updateSignedPsbt psbtBase64', psbtBase64)
this.$refs.paymentRef.updateSignedPsbt(psbtBase64) this.$refs.paymentRef.updateSignedPsbt(psbtBase64)
}, },
@ -237,7 +236,6 @@ const watchOnly = async () => {
}) })
this.addresses.push(...uniqueAddresses) this.addresses.push(...uniqueAddresses)
} }
console.log('### refreshAddresses', this.addresses)
this.$emit('update:addresses', this.addresses) this.$emit('update:addresses', this.addresses)
}, },
getAddressesForWallet: async function (walletId) { getAddressesForWallet: async function (walletId) {
@ -324,12 +322,14 @@ const watchOnly = async () => {
//################### MEMPOOL API ################### //################### MEMPOOL API ###################
getAddressTxsDelayed: async function (addrData) { getAddressTxsDelayed: async function (addrData) {
const accounts = this.walletAccounts
const {
bitcoin: {addresses: addressesAPI}
} = mempoolJS({
hostname: this.mempoolHostname
})
const fn = async () => { const fn = async () => {
const { if (!accounts.find(w => (w.id === addrData.wallet))) return []
bitcoin: {addresses: addressesAPI}
} = mempoolJS({
hostname: this.mempoolHostname
})
return addressesAPI.getAddressTxs({ return addressesAPI.getAddressTxs({
address: addrData.address address: addrData.address
}) })
@ -339,13 +339,15 @@ const watchOnly = async () => {
}, },
getAddressTxsUtxoDelayed: async function (address) { getAddressTxsUtxoDelayed: async function (address) {
const fn = async () => { const endpoint = this.mempoolHostname
const { const {
bitcoin: {addresses: addressesAPI} bitcoin: {addresses: addressesAPI}
} = mempoolJS({ } = mempoolJS({
hostname: this.mempoolHostname hostname: endpoint
}) })
const fn = async () => {
if (endpoint !== this.mempoolHostname) return []
return addressesAPI.getAddressTxsUtxo({ return addressesAPI.getAddressTxsUtxo({
address address
}) })

View file

@ -66,15 +66,14 @@ const mapAddressDataToUtxo = (wallet, addressData, utxo) => ({
selected: false selected: false
}) })
const mapWalletAccount = function (obj) { const mapWalletAccount = function (o) {
obj._data = _.clone(obj) return Object.assign({}, o, {
obj.date = obj.time date: o.time
? Quasar.utils.date.formatDate( ? Quasar.utils.date.formatDate(
new Date(obj.time * 1000), new Date(o.time * 1000),
'YYYY-MM-DD HH:mm' 'YYYY-MM-DD HH:mm'
) )
: '' : '',
obj.label = obj.title // for drop-downs expanded: false
obj.expanded = false })
return obj
} }