Skip to content

Commit 3a91a13

Browse files
committed
disable send when no prv
1 parent 7c334e2 commit 3a91a13

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

BDKSwiftExampleWallet/View Model/WalletViewModel.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ import Observation
1313
@Observable
1414
class WalletViewModel {
1515
let bdkClient: BDKClient
16+
let keyClient: KeyClient
1617
let priceClient: PriceClient
1718

1819
var balanceTotal: UInt64 = 0
20+
var canSend: Bool {
21+
guard let backupInfo = try? keyClient.getBackupInfo() else { return false }
22+
return backupInfo.descriptor.contains("tprv") || backupInfo.descriptor.contains("xprv")
23+
}
1924
var inspectedScripts: UInt64 = 0
2025
var price: Double = 0.00
2126
var progress: Float = 0.0
@@ -35,11 +40,13 @@ class WalletViewModel {
3540

3641
init(
3742
bdkClient: BDKClient = .live,
43+
keyClient: KeyClient = .live,
3844
priceClient: PriceClient = .live,
3945
transactions: [CanonicalTx] = [],
4046
walletSyncState: WalletSyncState = .notStarted
4147
) {
4248
self.bdkClient = bdkClient
49+
self.keyClient = keyClient
4350
self.priceClient = priceClient
4451
self.transactions = transactions
4552
self.walletSyncState = walletSyncState

BDKSwiftExampleWallet/View/WalletView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ struct WalletView: View {
191191
NavigationLink(value: NavigationDestination.address) {
192192
Image(systemName: "qrcode.viewfinder")
193193
.font(.title)
194-
.foregroundStyle(.primary)
194+
.foregroundStyle(viewModel.canSend ? .primary : .secondary)
195195
}
196+
.disabled(!viewModel.canSend)
196197
}
197198
.padding([.horizontal, .bottom])
198199

0 commit comments

Comments
 (0)