Add Monero subaccounts and subaddresses with a QR per address
This commit is contained in:
@@ -14,6 +14,7 @@ final class AppModel: ObservableObject {
|
||||
@Published var statusMessage: String?
|
||||
@Published var moneroReady = false
|
||||
@Published var moneroAddress: String?
|
||||
@Published var moneroAccounts: [MoneroAccount] = []
|
||||
/// Rough time remaining for the Monero sync, derived from observed block rate.
|
||||
@Published var syncEta: String?
|
||||
|
||||
@@ -228,8 +229,10 @@ final class AppModel: ObservableObject {
|
||||
if force || refreshTick == 1 || refreshTick % 4 == 0 {
|
||||
async let balanceCall = MoneroService.shared.balance()
|
||||
async let txCall = MoneroService.shared.transactions()
|
||||
async let accountsCall = MoneroService.shared.accounts()
|
||||
balance = try await balanceCall
|
||||
transactions = try await txCall
|
||||
moneroAccounts = try await accountsCall
|
||||
}
|
||||
} catch {
|
||||
errorMessage = error.localizedDescription
|
||||
@@ -345,6 +348,24 @@ final class AppModel: ObservableObject {
|
||||
await MoneroService.shared.save()
|
||||
}
|
||||
|
||||
func addAccount(label: String = "") async throws {
|
||||
_ = try await MoneroService.shared.createAccount(label: label)
|
||||
await refresh(force: true)
|
||||
}
|
||||
|
||||
func addSubaddress(accountIndex: Int, label: String = "") async throws {
|
||||
_ = try await MoneroService.shared.createSubaddress(accountIndex: accountIndex, label: label)
|
||||
await refresh(force: true)
|
||||
}
|
||||
|
||||
/// Refreshes the account/subaddress tree independently of the active chain.
|
||||
func loadAccounts() async {
|
||||
guard moneroReady else { return }
|
||||
if let accounts = try? await MoneroService.shared.accounts() {
|
||||
moneroAccounts = accounts
|
||||
}
|
||||
}
|
||||
|
||||
/// monero-cpp only writes the wallet file from save(), and its sync loop
|
||||
/// never does, so without this a restart re-scans from the beginning.
|
||||
private func checkpointWalletIfSyncing() async {
|
||||
|
||||
Reference in New Issue
Block a user