Skip to content
Closed
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9a4ea77
tests
r1b2ns May 24, 2025
e188b6c
added sentAndReceived
r1b2ns May 24, 2025
572942f
implemented new functions
r1b2ns May 24, 2025
01be1b9
fix secret
r1b2ns May 24, 2025
899457e
fix create new wallet
r1b2ns May 24, 2025
8b66948
chore: removed comments
r1b2ns May 24, 2025
ebe05e9
added kyoto structure
r1b2ns May 24, 2025
a0708dd
Added Kyoto sync
r1b2ns May 24, 2025
91acf93
no message
r1b2ns May 24, 2025
8af10a8
no message
r1b2ns May 25, 2025
9f770fe
removed ActivityListViewModel dead code
r1b2ns May 25, 2025
0b490db
no message
r1b2ns May 25, 2025
8c2a9d9
fix the code
r1b2ns May 25, 2025
bf844b5
chore: organizing code
r1b2ns May 25, 2025
c13fc74
testing kyoto
r1b2ns May 25, 2025
db1a908
added Kyoto stop service
r1b2ns May 25, 2025
93562f2
organize code
r1b2ns May 25, 2025
e1543e2
no message
r1b2ns May 25, 2025
a8d06f7
clean dead code
r1b2ns May 25, 2025
4a9a4fd
create live for EsploraService and KyotoService
r1b2ns May 25, 2025
f7cf0ad
test main net
r1b2ns May 25, 2025
d46e6f3
testing main net with bip84
r1b2ns May 25, 2025
a6ee9bf
chore: removed main net
r1b2ns May 26, 2025
37046bf
feat: added option to in onboard to synchronise using kyoto and savin…
r1b2ns May 26, 2025
19a8518
organize code
r1b2ns May 26, 2025
a37b954
added getSyncMode
r1b2ns May 26, 2025
cc2e69d
added kyoto in settings
r1b2ns May 26, 2025
a646078
fix needFullScan
r1b2ns May 26, 2025
699385a
no message
r1b2ns May 26, 2025
0540621
swift-format
r1b2ns May 26, 2025
59e039e
fix: using concrete type for EsploraService and Kyoto
r1b2ns Jun 5, 2025
7b7e2ab
added .live
r1b2ns Jun 5, 2025
3f0341b
code review fixe
r1b2ns Jun 5, 2025
608aecd
Code review fixes
r1b2ns Jun 5, 2025
79a94be
code review fixes
r1b2ns Jun 5, 2025
2521e9d
Removed full scan when syncing with Kyoto
r1b2ns Jun 13, 2025
ddf573f
feat: Added circular progress view
r1b2ns Jun 13, 2025
be0e172
Removed option to choose network when using kyoto
r1b2ns Jun 13, 2025
364a996
added automatic update
r1b2ns Jun 17, 2025
840e0f8
added network indicator
r1b2ns Jun 17, 2025
2a109a3
realtime update wallet
r1b2ns Jun 17, 2025
531cc7b
Stop any service when delete a wallet
r1b2ns Jun 17, 2025
35c7072
removed taprootheight
r1b2ns Jun 17, 2025
98f86d8
no message
r1b2ns Jun 17, 2025
13a363b
fix onboarding
r1b2ns Jun 17, 2025
3c5cdf4
chore: swift-format
r1b2ns Jun 17, 2025
a05f172
code review fix
r1b2ns Jun 18, 2025
ce793a9
Code review fixes
r1b2ns Jun 18, 2025
71507d4
code review fix
r1b2ns Jun 18, 2025
57620a2
code review fix
r1b2ns Jun 18, 2025
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
40 changes: 40 additions & 0 deletions BDKSwiftExampleWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
779E70872DB9C98A006E22D3 /* WalletSyncScriptInspector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 779E70862DB9C98A006E22D3 /* WalletSyncScriptInspector.swift */; };
779E70892DB9C9AB006E22D3 /* WalletFullScanScriptInspector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 779E70882DB9C9AB006E22D3 /* WalletFullScanScriptInspector.swift */; };
77AD9F062DBB031D00182E65 /* ActivityHomeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77AD9F052DBB031D00182E65 /* ActivityHomeHeaderView.swift */; };
77DB13092DEBB4AC004B735D /* BDKClient+Kyoto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77DB13082DEBB4A9004B735D /* BDKClient+Kyoto.swift */; };
77DB130B2DEBB553004B735D /* BDKClient+Esplora.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77DB130A2DEBB550004B735D /* BDKClient+Esplora.swift */; };
77F0FDC92DA9A93D00B30E4F /* Connection+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F0FDC82DA9A93700B30E4F /* Connection+Extensions.swift */; };
77F6A9E32DE247B2003568F0 /* BDKSyncService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F6A9E22DE247AD003568F0 /* BDKSyncService.swift */; };
77F6A9E52DE24841003568F0 /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F6A9E42DE24837003568F0 /* URL+Extensions.swift */; };
77F6A9E72DE248A2003568F0 /* EsploraService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F6A9E62DE248A1003568F0 /* EsploraService.swift */; };
77F6A9E92DE25C9C003568F0 /* KyotoService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F6A9E82DE25C98003568F0 /* KyotoService.swift */; };
77F6A9EB2DE5072E003568F0 /* AppStorageUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F6A9EA2DE50727003568F0 /* AppStorageUtil.swift */; };
77F80F582DFCC33D002ACBA2 /* CircularProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77F80F572DFCC33D002ACBA2 /* CircularProgressView.swift */; };
A733D6D02A81113000F333B4 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = A733D6CF2A81113000F333B4 /* Localizable.xcstrings */; };
A73F7A362A3B778E00B87FC6 /* Int+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A73F7A352A3B778E00B87FC6 /* Int+Extensions.swift */; };
AE0C30F72A804A2D008F1EAE /* TransactionListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE0C30F62A804A2D008F1EAE /* TransactionListView.swift */; };
Expand Down Expand Up @@ -116,7 +124,15 @@
779E70862DB9C98A006E22D3 /* WalletSyncScriptInspector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletSyncScriptInspector.swift; sourceTree = "<group>"; };
779E70882DB9C9AB006E22D3 /* WalletFullScanScriptInspector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletFullScanScriptInspector.swift; sourceTree = "<group>"; };
77AD9F052DBB031D00182E65 /* ActivityHomeHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityHomeHeaderView.swift; sourceTree = "<group>"; };
77DB13082DEBB4A9004B735D /* BDKClient+Kyoto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BDKClient+Kyoto.swift"; sourceTree = "<group>"; };
77DB130A2DEBB550004B735D /* BDKClient+Esplora.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BDKClient+Esplora.swift"; sourceTree = "<group>"; };
77F0FDC82DA9A93700B30E4F /* Connection+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Connection+Extensions.swift"; sourceTree = "<group>"; };
77F6A9E22DE247AD003568F0 /* BDKSyncService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BDKSyncService.swift; sourceTree = "<group>"; };
77F6A9E42DE24837003568F0 /* URL+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Extensions.swift"; sourceTree = "<group>"; };
77F6A9E62DE248A1003568F0 /* EsploraService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EsploraService.swift; sourceTree = "<group>"; };
77F6A9E82DE25C98003568F0 /* KyotoService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KyotoService.swift; sourceTree = "<group>"; };
77F6A9EA2DE50727003568F0 /* AppStorageUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStorageUtil.swift; sourceTree = "<group>"; };
77F80F572DFCC33D002ACBA2 /* CircularProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressView.swift; sourceTree = "<group>"; };
A733D6CF2A81113000F333B4 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
A73F7A352A3B778E00B87FC6 /* Int+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Int+Extensions.swift"; sourceTree = "<group>"; };
AE0C30F62A804A2D008F1EAE /* TransactionListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionListView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -246,6 +262,16 @@
path = Home;
sourceTree = "<group>";
};
77F6A9E12DE247A3003568F0 /* BDKSyncService */ = {
isa = PBXGroup;
children = (
77F6A9E82DE25C98003568F0 /* KyotoService.swift */,
77F6A9E62DE248A1003568F0 /* EsploraService.swift */,
77F6A9E22DE247AD003568F0 /* BDKSyncService.swift */,
);
path = BDKSyncService;
sourceTree = "<group>";
};
A7FBCE392A72944C007C960E /* Resources */ = {
isa = PBXGroup;
children = (
Expand All @@ -271,6 +297,7 @@
AE1C341E2A42440A008F807A /* Extensions */ = {
isa = PBXGroup;
children = (
77F6A9E42DE24837003568F0 /* URL+Extensions.swift */,
AE18E9372A9528200019D2A4 /* Bundle+Extensions.swift */,
AE3646252BEDB01200B04E25 /* FileManager+Extensions.swift */,
A73F7A352A3B778E00B87FC6 /* Int+Extensions.swift */,
Expand Down Expand Up @@ -302,6 +329,7 @@
AE1C34202A42441F008F807A /* Utilities */ = {
isa = PBXGroup;
children = (
77F6A9EA2DE50727003568F0 /* AppStorageUtil.swift */,
AE79538D2A2D59F000CCB277 /* Constants.swift */,
AE2F255C2BED0BFB002A9AC6 /* AppError.swift */,
);
Expand All @@ -311,6 +339,8 @@
AE1C34212A424434008F807A /* BDK Service */ = {
isa = PBXGroup;
children = (
77DB130A2DEBB550004B735D /* BDKClient+Esplora.swift */,
77DB13082DEBB4A9004B735D /* BDKClient+Kyoto.swift */,
AED4CC092A1D297600CE1831 /* BDKService.swift */,
AE79538F2A2D5B4400CCB277 /* BDKSwiftExampleWalletError.swift */,
);
Expand All @@ -335,6 +365,7 @@
AE2381B62C61253200F6B00C /* Activity */ = {
isa = PBXGroup;
children = (
77F80F572DFCC33D002ACBA2 /* CircularProgressView.swift */,
AE2381AC2C60578500F6B00C /* ActivityListView.swift */,
AE0C30F62A804A2D008F1EAE /* TransactionListView.swift */,
AE29ED102BBE318A00EB9C4F /* TransactionItemView.swift */,
Expand Down Expand Up @@ -512,6 +543,7 @@
AEB905C52A7EECD900CD0337 /* Service */ = {
isa = PBXGroup;
children = (
77F6A9E12DE247A3003568F0 /* BDKSyncService */,
AE1C34212A424434008F807A /* BDK Service */,
AEB905C42A7EECAF00CD0337 /* Price Service */,
AE6715FB2A9ABF30005C193F /* Fee Service */,
Expand Down Expand Up @@ -690,6 +722,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
77F6A9E32DE247B2003568F0 /* BDKSyncService.swift in Sources */,
AE83EFDB2C9D07B200B41244 /* ChainPosition+Extensions.swift in Sources */,
AE2ADD782B61EFFF00C2A823 /* SettingsViewModel.swift in Sources */,
AEAB03112ABDDB86000C9528 /* FeeViewModel.swift in Sources */,
Expand All @@ -699,13 +732,15 @@
774586B52DB7B2BC00A631E1 /* BalanceView.swift in Sources */,
AEB905C32A7EEBF000CD0337 /* BackupInfo.swift in Sources */,
AE783A072AB4F7C7005F0CBA /* FeeView.swift in Sources */,
77F6A9E92DE25C9C003568F0 /* KyotoService.swift in Sources */,
AE2B8C1D2A9678C900815B2F /* FeeService.swift in Sources */,
AE8D001C2D19F1760029C4C9 /* UIScreen+Extensions.swift in Sources */,
AEC2CF5A2ABFBA19008065E4 /* BuildTransactionViewModel.swift in Sources */,
AE2B8C1F2A96797300815B2F /* RecommendedFees.swift in Sources */,
AE7F670C2A7451D700CED561 /* CurrencyCode.swift in Sources */,
AE2ADD762B61EFEB00C2A823 /* HomeViewModel.swift in Sources */,
AE783A032AB4ECC2005F0CBA /* AddressView.swift in Sources */,
77F6A9E52DE24841003568F0 /* URL+Extensions.swift in Sources */,
AEB159D52D51A8680006AE9E /* View+Extensions.swift in Sources */,
AE7F67052A7446B600CED561 /* PriceService.swift in Sources */,
AEAB03132ABDDBF4000C9528 /* AmountViewModel.swift in Sources */,
Expand All @@ -717,6 +752,7 @@
AEB159D32D51A7E00006AE9E /* BalanceDisplayFormat.swift in Sources */,
AE18E9382A9528200019D2A4 /* Bundle+Extensions.swift in Sources */,
AE79538E2A2D59F000CCB277 /* Constants.swift in Sources */,
77F80F582DFCC33D002ACBA2 /* CircularProgressView.swift in Sources */,
AE2F255D2BED0BFB002A9AC6 /* AppError.swift in Sources */,
AEE6C74F2ABCBA4600442ADD /* WalletSyncState.swift in Sources */,
AE1C34242A424456008F807A /* ReceiveView.swift in Sources */,
Expand Down Expand Up @@ -746,8 +782,11 @@
AE6716012A9AC089005C193F /* KeyServiceError.swift in Sources */,
77AD9F062DBB031D00182E65 /* ActivityHomeHeaderView.swift in Sources */,
AE0C30FB2A804B95008F1EAE /* WalletViewModel.swift in Sources */,
77DB130B2DEBB553004B735D /* BDKClient+Esplora.swift in Sources */,
77F6A9EB2DE5072E003568F0 /* AppStorageUtil.swift in Sources */,
AE49847C2A1BBBD6009951E2 /* BDKSwiftExampleWalletApp.swift in Sources */,
AE6715FF2A9AC066005C193F /* FeeServiceError.swift in Sources */,
77DB13092DEBB4AC004B735D /* BDKClient+Kyoto.swift in Sources */,
AE2381AD2C60578500F6B00C /* ActivityListView.swift in Sources */,
AE2381B32C60877600F6B00C /* LocalOutputListView.swift in Sources */,
AE783A052AB4F51F005F0CBA /* String+Extensions.swift in Sources */,
Expand All @@ -756,6 +795,7 @@
AE0C30F92A804B65008F1EAE /* OnboardingViewModel.swift in Sources */,
AE3902A42A3B4CD900BEC318 /* HomeView.swift in Sources */,
AE0C30FD2A804BC1008F1EAE /* ReceiveViewModel.swift in Sources */,
77F6A9E72DE248A2003568F0 /* EsploraService.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
17 changes: 12 additions & 5 deletions BDKSwiftExampleWallet/App/BDKSwiftExampleWalletApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ struct BDKSwiftExampleWalletApp: App {
WindowGroup {
NavigationStack(path: $navigationPath) {
let value = try? KeyClient.live.getBackupInfo()
if isOnboarding && (value == nil) {
OnboardingView(viewModel: .init(bdkClient: .live))
} else if !isOnboarding && (value == nil) {
OnboardingView(viewModel: .init(bdkClient: .live))
if value != nil && !isOnboarding {
HomeView(
viewModel: .init(
bdkClient: .live
),
navigationPath: $navigationPath
)
} else {
HomeView(viewModel: .init(bdkClient: .live), navigationPath: $navigationPath)
OnboardingView(
viewModel: .init(
bdkClient: .live
)
)
}
}
.onChange(of: isOnboarding) { oldValue, newValue in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import BitcoinDevKit
import Foundation

extension Connection {
static var dataDir: String {
let documentsDirectoryURL = URL.documentsDirectory
let walletDataDirectoryURL = documentsDirectoryURL.appendingPathComponent("wallet_data")
return walletDataDirectoryURL.path()
}

static func createConnection() throws -> Connection {
let documentsDirectoryURL = URL.documentsDirectory
let walletDataDirectoryURL = documentsDirectoryURL.appendingPathComponent("wallet_data")
Expand All @@ -17,4 +23,10 @@ extension Connection {
let connection = try Connection(path: persistenceBackendPath)
return connection
}

static func loadConnection() throws -> Connection {
let persistenceBackendPath = URL.persistenceBackendPath
let connection = try Connection(path: persistenceBackendPath)
return connection
}
}
31 changes: 31 additions & 0 deletions BDKSwiftExampleWallet/Extensions/URL+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// URL+Extensions.swift
// BDKSwiftExampleWallet
//
// Created by Rubens Machion on 17/05/25.
//

import Foundation

extension URL {

static var defaultWalletDirectory: URL {
URL.documentsDirectory
}

static var walletDirectoryName: String {
"wallet_data"
}

static var walletDBName: String {
"wallet.sqlite"
}

static var walletDataDirectoryURL: URL {
defaultWalletDirectory.appendingPathComponent(walletDirectoryName)
}

static var persistenceBackendPath: String {
walletDataDirectoryURL.appendingPathComponent(walletDBName).path
}
}
2 changes: 1 addition & 1 deletion BDKSwiftExampleWallet/Model/BackupInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct BackupInfo: Codable, Equatable {
var descriptor: String
var changeDescriptor: String

init(mnemonic: String, descriptor: String, changeDescriptor: String) {
init(mnemonic: String = "", descriptor: String, changeDescriptor: String) {
self.mnemonic = mnemonic
self.descriptor = descriptor
self.changeDescriptor = changeDescriptor
Expand Down
12 changes: 12 additions & 0 deletions BDKSwiftExampleWallet/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@
}
}
}
},
"%lld%%" : {

},
"%llu" : {
"localizations" : {
Expand Down Expand Up @@ -451,6 +454,9 @@
}
}
}
},
"Conecting" : {

},
"confirmed" : {
"localizations" : {
Expand Down Expand Up @@ -691,6 +697,9 @@
}
}
}
},
"Kyoto" : {

},
"Navigation Title" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -1143,6 +1152,9 @@
}
}
}
},
"Sync type" : {

},
"Syncing" : {
"extractionState" : "manual",
Expand Down
99 changes: 99 additions & 0 deletions BDKSwiftExampleWallet/Service/BDK Service/BDKClient+Esplora.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
//
// BDKClient+Esplora.swift
// BDKSwiftExampleWallet
//
// Created by Rubens Machion on 31/05/25.
//

extension BDKClient {
static let esplora = Self(
loadWallet: {
try EsploraService.shared.loadWallet()
},
deleteWallet: {
try EsploraService.shared.deleteWallet()
},
createWalletFromSeed: { words in
try EsploraService.shared.createWallet(params: words)
},
createWalletFromDescriptor: { descriptor in
try EsploraService.shared.createWallet(params: descriptor)
},
createWalletFromXPub: { xpub in
try EsploraService.shared.createWallet(params: xpub)
},
getBalance: {
try EsploraService.shared.getBalance()
},
transactions: {
try EsploraService.shared.getTransactions()
},
listUnspent: {
try EsploraService.shared.listUnspent()
},
syncScanWithSyncScanProgress: { progress in
try await EsploraService.shared.startSync(progress: progress)
},
fullScanWithFullScanProgress: { progress in
try await EsploraService.shared.startFullScan(progress: progress)
},
getAddress: {
try EsploraService.shared.getAddress()
},
send: { (address, amount, feeRate) in
Task {
try await EsploraService.shared.send(
address: address,
amount: amount,
feeRate: feeRate
)
}
},
calculateFee: { tx in
try EsploraService.shared.calculateFee(tx: tx)
},
calculateFeeRate: { tx in
try EsploraService.shared.calculateFeeRate(tx: tx)
},
sentAndReceived: { tx in
try EsploraService.shared.sentAndReceived(tx: tx)
},
buildTransaction: { (address, amount, feeRate) in
try EsploraService.shared.buildTransaction(
address: address,
amount: amount,
feeRate: feeRate
)
},
getBackupInfo: {
try BDKService.shared.getBackupInfo()
},
needsFullScan: {
BDKService.shared.needsFullScanOfWallet()
},
setNeedsFullScan: { value in
BDKService.shared.setNeedsFullScan(value)
},
getNetwork: {
BDKService.shared.network
},
getEsploraURL: {
BDKService.shared.esploraURL
},
updateNetwork: { newNetwork in
BDKService.shared.updateNetwork(newNetwork)
},
updateEsploraURL: { newURL in
BDKService.shared.updateEsploraURL(newURL)
},
stop: {
try await EsploraService.shared.stopService()
},
upateSyncMode: { mode in
BDKService.shared.updateSyncMode(mode)
},
getSyncMode: {
BDKService.shared.getSyncMode()
}
)
}
Loading