Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import Foundation

extension Notification.Name {
static let walletCreated = Notification.Name("walletCreated")
static let walletDidUpdate = Notification.Name("walletDidUpdate")
}
2 changes: 2 additions & 0 deletions BDKSwiftExampleWallet/Service/BDK Service/BDKService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ final class BDKService {
throw WalletError.dbNotFound
}
let _ = try wallet.persist(persister: persister)
NotificationCenter.default.post(name: .walletDidUpdate, object: nil)
}

func fullScanWithInspector(inspector: FullScanScriptInspector) async throws {
Expand All @@ -663,6 +664,7 @@ final class BDKService {
throw WalletError.dbNotFound
}
let _ = try wallet.persist(persister: persister)
NotificationCenter.default.post(name: .walletDidUpdate, object: nil)
}

func calculateFee(tx: Transaction) throws -> Amount {
Expand Down
13 changes: 13 additions & 0 deletions BDKSwiftExampleWallet/View Model/WalletViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ class WalletViewModel {
}
}
}

NotificationCenter.default.addObserver(
forName: .walletDidUpdate,
object: nil,
queue: .main
) { [weak self] _ in
guard let self else { return }
self.getBalance()
self.getTransactions()
Task {
await self.getPrices()
}
}
}

private func fullScanWithProgress() async {
Expand Down