Skip to content

Commit 0b490db

Browse files
committed
no message
1 parent 9f770fe commit 0b490db

File tree

7 files changed

+18
-95
lines changed

7 files changed

+18
-95
lines changed

BDKSwiftExampleWallet/Actor/WalletFullScanScriptInspector.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by Rubens Machion on 23/04/25.
66
//
77

8+
89
import BitcoinDevKit
910

1011
actor WalletFullScanScriptInspector: @preconcurrency FullScanScriptInspector {

BDKSwiftExampleWallet/Service/BDK Service/BDKService.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ private class BDKService {
114114
{
115115
try service.buildTransaction(address: address, amount: amount, feeRate: feeRate)
116116
}
117-
118-
func syncWithInspector(inspector: SyncScriptInspector) async throws {
119-
try await service.startSync(progress: inspector)
120-
}
121-
122-
func fullScanWithInspector(inspector: FullScanScriptInspector) async throws {
123-
try await service.startFullScan(progress: inspector)
124-
}
125117

126118
func syncWithInspector2(progress: @escaping SyncScanProgress) async throws {
127119
try await service.startSync2(progress: progress)
@@ -163,8 +155,6 @@ struct BDKClient {
163155
let getBalance: () throws -> Balance
164156
let transactions: () throws -> [CanonicalTx]
165157
let listUnspent: () throws -> [LocalOutput]
166-
let syncWithInspector: (SyncScriptInspector) async throws -> Void
167-
let fullScanWithInspector: (FullScanScriptInspector) async throws -> Void
168158
let syncScanWithSyncScanProgress: (@escaping SyncScanProgress) async throws -> Void
169159
let fullScanWithFullScanProgress: (@escaping FullScanProgress) async throws -> Void
170160
let getAddress: () throws -> String
@@ -196,12 +186,6 @@ extension BDKClient {
196186
getBalance: { try BDKService.shared.getBalance() },
197187
transactions: { try BDKService.shared.transactions() },
198188
listUnspent: { try BDKService.shared.listUnspent() },
199-
syncWithInspector: { inspector in
200-
try await BDKService.shared.syncWithInspector(inspector: inspector)
201-
},
202-
fullScanWithInspector: { inspector in
203-
try await BDKService.shared.fullScanWithInspector(inspector: inspector)
204-
},
205189
syncScanWithSyncScanProgress: { progress in
206190
try await BDKService.shared.syncWithInspector2(progress: progress)
207191
},
@@ -261,8 +245,6 @@ extension BDKClient {
261245
.mock
262246
]
263247
},
264-
syncWithInspector: { _ in },
265-
fullScanWithInspector: { _ in },
266248
syncScanWithSyncScanProgress: { _ in },
267249
fullScanWithFullScanProgress: { _ in },
268250
getAddress: { "tb1pd8jmenqpe7rz2mavfdx7uc8pj7vskxv4rl6avxlqsw2u8u7d4gfs97durt" },

BDKSwiftExampleWallet/Service/BDKSyncService/BDKSyncService.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ protocol BDKSyncService {
1919

2020
func createWallet(params: String?) throws
2121
func loadWallet() throws
22-
func deleteWallet() throws
23-
func startSync(progress: SyncScriptInspector) async throws
24-
func startFullScan(progress: FullScanScriptInspector) async throws
25-
22+
func deleteWallet() throws
2623
func startSync2(progress: @escaping SyncScanProgress) async throws
2724
func startFullScan2(progress: @escaping FullScanProgress) async throws
2825

BDKSwiftExampleWallet/Service/BDKSyncService/EsploraService.swift

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,6 @@ final class EsploraService: BDKSyncService {
5454
self.esploraClient = .init(url: url)
5555
}
5656

57-
func startSync(progress: SyncScriptInspector) async throws {
58-
guard let wallet = self.wallet else { throw WalletError.walletNotFound }
59-
let esploraClient = self.esploraClient
60-
let syncRequest = try wallet.startSyncWithRevealedSpks()
61-
.inspectSpks(inspector: progress)
62-
.build()
63-
let update = try esploraClient.sync(
64-
request: syncRequest,
65-
parallelRequests: UInt64(5)
66-
)
67-
let _ = try wallet.applyUpdate(update: update)
68-
guard let connection = self.connection else {
69-
throw WalletError.dbNotFound
70-
}
71-
let _ = try wallet.persist(connection: connection)
72-
}
73-
7457
func startSync2(progress: @escaping SyncScanProgress) async throws {
7558
guard let wallet = self.wallet else { throw WalletError.walletNotFound }
7659
let syncScanInspector = WalletSyncScriptInspector { scripts, total in
@@ -114,26 +97,6 @@ final class EsploraService: BDKSyncService {
11497
let _ = try wallet.persist(connection: connection)
11598
}
11699

117-
func startFullScan(progress: FullScanScriptInspector) async throws {
118-
guard let wallet = self.wallet else { throw WalletError.walletNotFound }
119-
let esploraClient = esploraClient
120-
let fullScanRequest = try wallet.startFullScan()
121-
.inspectSpksForAllKeychains(inspector: progress)
122-
.build()
123-
let update = try esploraClient.fullScan(
124-
request: fullScanRequest,
125-
// using https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#address-gap-limit
126-
stopGap: UInt64(20),
127-
// using https://github.com/bitcoindevkit/bdk/blob/master/example-crates/example_wallet_esplora_blocking/src/main.rs
128-
parallelRequests: UInt64(5)
129-
)
130-
let _ = try wallet.applyUpdate(update: update)
131-
guard let connection = self.connection else {
132-
throw WalletError.dbNotFound
133-
}
134-
let _ = try wallet.persist(connection: connection)
135-
}
136-
137100
func send(
138101
address: String,
139102
amount: UInt64,

BDKSwiftExampleWallet/Service/BDKSyncService/KyotoService.swift

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ final class KyotoService: BDKSyncService {
2323
private var node: CbfNode?
2424
private var connected = false
2525

26-
private var fullScanProgress: FullScanScriptInspector?
2726
private var fullScanProgress2: FullScanProgress?
28-
private var syncProgress: SyncScriptInspector?
27+
private var syncProgress: SyncScanProgress?
2928

3029
init(
3130
keyClient: KeyClient = .live,
@@ -48,34 +47,17 @@ final class KyotoService: BDKSyncService {
4847
self.wallet = wallet
4948
}
5049

51-
func startSync(progress: SyncScriptInspector) async throws {
52-
// guard let wallet = self.wallet else {
53-
// throw WalletError.walletNotFound
54-
// }
55-
// let nodeComponents = try buildNode(
56-
// from: wallet, scanType: .sync
57-
// )
58-
// self.syncProgress = progress
59-
// self.client = nodeComponents.client
60-
// self.node = nodeComponents.node
61-
// await startListen()
62-
}
63-
64-
func startFullScan(progress: FullScanScriptInspector) async throws {
65-
// guard let wallet = self.wallet else {
66-
// throw WalletError.walletNotFound
67-
// }
68-
// let nodeComponents = try buildNode(
69-
// from: wallet, scanType: .recovery(fromHeight: 200_000)
70-
// )
71-
// self.fullScanProgress = progress
72-
// self.client = nodeComponents.client
73-
// self.node = nodeComponents.node
74-
// await startListen()
75-
}
76-
7750
func startSync2(progress: @escaping SyncScanProgress) async throws {
78-
51+
guard let wallet = self.wallet else {
52+
throw WalletError.walletNotFound
53+
}
54+
let nodeComponents = try buildNode(
55+
from: wallet, scanType: .sync
56+
)
57+
self.syncProgress = progress
58+
self.client = nodeComponents.client
59+
self.node = nodeComponents.node
60+
try await startListen()
7961
}
8062

8163
func startFullScan2(progress: @escaping FullScanProgress) async throws {

BDKSwiftExampleWallet/View Model/Settings/SettingsViewModel.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ class SettingsViewModel: ObservableObject {
5252
self.walletSyncState = .syncing
5353
}
5454
do {
55-
let inspector = WalletFullScanScriptInspector(updateProgress: updateProgressFullScan)
56-
try await bdkClient.fullScanWithInspector(inspector)
55+
try await bdkClient.fullScanWithFullScanProgress { [weak self] progress in
56+
DispatchQueue.main.async {
57+
self?.inspectedScripts = progress
58+
}
59+
}
5760
DispatchQueue.main.async {
5861
NotificationCenter.default.post(
5962
name: Notification.Name("TransactionSent"),

BDKSwiftExampleWallet/View Model/WalletViewModel.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ class WalletViewModel {
124124
private func startSyncWithProgress() async {
125125
self.walletSyncState = .syncing
126126
do {
127-
// let inspector = WalletSyncScriptInspector(updateProgress: updateProgress)
128-
// try await bdkClient.syncWithInspector(inspector)
129-
130127
try await bdkClient.syncScanWithSyncScanProgress { [weak self] inspected, total in
131128
DispatchQueue.main.async {
132129
self?.totalScripts = total
@@ -156,8 +153,6 @@ class WalletViewModel {
156153
private func fullScanWithProgress() async {
157154
self.walletSyncState = .syncing
158155
do {
159-
// let inspector = WalletFullScanScriptInspector(updateProgress: updateProgressFullScan)
160-
// try await bdkClient.fullScanWithInspector(inspector)
161156
try await bdkClient.fullScanWithFullScanProgress { [weak self] progress in
162157
DispatchQueue.main.async {
163158
self?.inspectedScripts = progress

0 commit comments

Comments
 (0)