auto-detect existing wallets, show selectable list on startup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { MoneroWalletRpc, MoneroRpcConnection, connectToWalletRpc, connectToDaemonRpc } from 'monero-ts'
|
||||
import { getBinaryPath, getWalletDir } from './binary'
|
||||
import { existsSync } from 'fs'
|
||||
import { existsSync, readdirSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
const DEFAULT_DAEMON = 'xmr-node.cakewallet.com:18081'
|
||||
|
||||
@@ -18,6 +19,17 @@ export class MoneroWalletManager {
|
||||
this.rpcPassword = crypto.randomUUID()
|
||||
}
|
||||
|
||||
listWallets(): string[] {
|
||||
const dir = getWalletDir()
|
||||
if (!existsSync(dir)) return []
|
||||
const files = readdirSync(dir)
|
||||
const wallets = files
|
||||
.filter(f => f.endsWith('.keys'))
|
||||
.map(f => f.replace(/\.keys$/, ''))
|
||||
console.log(`[monero] wallets on disk: ${wallets.join(', ') || 'none'}`)
|
||||
return wallets
|
||||
}
|
||||
|
||||
private get rpcUrl() {
|
||||
return `http://127.0.0.1:${this.rpcPort}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user