fix: refresh when both onchain and ln are present

This commit is contained in:
Vlad Stan
2022-11-24 17:33:58 +02:00
parent d3c3622d22
commit 3356bab5ca

View File

@ -328,7 +328,8 @@
}, },
methods: { methods: {
checkBalances: async function () { checkBalances: async function () {
if (this.charge.hasStaleBalance) return if (!this.charge.lnbitswallet && this.charge.hasOnchainStaleBalance)
return
try { try {
const {data} = await LNbits.api.request( const {data} = await LNbits.api.request(
'GET', 'GET',
@ -353,7 +354,7 @@
address: this.charge.onchainaddress address: this.charge.onchainaddress
}) })
const newBalance = utxos.reduce((t, u) => t + u.value, 0) const newBalance = utxos.reduce((t, u) => t + u.value, 0)
this.charge.hasStaleBalance = this.charge.balance === newBalance this.charge.hasOnchainStaleBalance = this.charge.balance === newBalance
this.pendingFunds = utxos this.pendingFunds = utxos
.filter(u => !u.status.confirmed) .filter(u => !u.status.confirmed)
@ -430,6 +431,7 @@
created: async function () { created: async function () {
if (this.charge.lnbitswallet) this.payInvoice() if (this.charge.lnbitswallet) this.payInvoice()
else this.payOnchain() else this.payOnchain()
await this.checkBalances() await this.checkBalances()
if (!this.charge.paid) { if (!this.charge.paid) {