fix walletOpen status always returning true

This commit is contained in:
2026-05-17 10:48:35 +08:00
parent e6ed6445ad
commit 23b7447b92
2 changed files with 15 additions and 3 deletions
+3 -2
View File
@@ -612,8 +612,9 @@ const rpc = BrowserView.defineRPC<RPC>({
return { running: false, walletOpen: false, connected: false } return { running: false, walletOpen: false, connected: false }
} }
const connected = await moneroManager.isConnected() const connected = await moneroManager.isConnected()
console.log('[rpc] moneroWalletStatus: running, connected:', connected) const walletOpen = await moneroManager.isWalletOpen()
return { running: true, walletOpen: true, connected } console.log('[rpc] moneroWalletStatus: running, walletOpen:', walletOpen, 'connected:', connected)
return { running: true, walletOpen, connected }
}, },
moneroGetAccounts: async () => { moneroGetAccounts: async () => {
console.log('[rpc] moneroGetAccounts') console.log('[rpc] moneroGetAccounts')
+12 -1
View File
@@ -218,11 +218,22 @@ export class MoneroWalletManager {
} }
} }
async isConnected(): Promise<boolean> { async isWalletOpen(): Promise<boolean> {
if (!this.wallet) return false if (!this.wallet) return false
try { try {
await this.wallet.getHeight() await this.wallet.getHeight()
return true return true
} catch {
return false
}
}
async isConnected(): Promise<boolean> {
if (!this.wallet) return false
try {
const daemon = await connectToDaemonRpc(`http://${this.daemonAddress}`)
await daemon.getHeight()
return true
} catch (e) { } catch (e) {
console.log(`[monero] connection check failed:`, e) console.log(`[monero] connection check failed:`, e)
return false return false