@@ -10,9 +10,9 @@ import kotlinx.coroutines.runBlocking
1010import org.bitcoindevkit.Address
1111import org.bitcoindevkit.AddressInfo
1212import org.bitcoindevkit.Amount
13+ import org.bitcoindevkit.BlockId
1314import org.bitcoindevkit.CanonicalTx
1415import org.bitcoindevkit.ChainPosition
15- import org.bitcoindevkit.Connection
1616import org.bitcoindevkit.Descriptor
1717import org.bitcoindevkit.DescriptorSecretKey
1818import org.bitcoindevkit.FeeRate
@@ -39,6 +39,7 @@ import org.bitcoindevkit.devkitwallet.domain.utils.intoDomain
3939import org.bitcoindevkit.devkitwallet.domain.utils.intoProto
4040import org.bitcoindevkit.devkitwallet.presentation.viewmodels.mvi.Recipient
4141import org.bitcoindevkit.CbfClient
42+ import org.bitcoindevkit.Persister
4243import java.util.UUID
4344import org.bitcoindevkit.Wallet as BdkWallet
4445
@@ -47,7 +48,7 @@ private const val TAG = "Wallet"
4748class Wallet private constructor(
4849 private val wallet : BdkWallet ,
4950 private val walletSecrets : WalletSecrets ,
50- private val connection : Connection ,
51+ private val connection : Persister ,
5152 private var fullScanCompleted : Boolean ,
5253 private val walletId : String ,
5354 private val userPreferencesRepository : UserPreferencesRepository ,
@@ -117,7 +118,7 @@ class Wallet private constructor(
117118 fun broadcast (signedPsbt : Psbt ): String {
118119 currentBlockchainClient?.broadcast(signedPsbt.extractTx())
119120 ? : throw IllegalStateException (" Blockchain client not initialized" )
120- return signedPsbt.extractTx().computeTxid()
121+ return signedPsbt.extractTx().computeTxid().toString()
121122 }
122123
123124 private fun getAllTransactions (): List <CanonicalTx > = wallet.transactions()
@@ -153,7 +154,7 @@ class Wallet private constructor(
153154 }
154155 TxDetails (
155156 tx.transaction,
156- txid,
157+ txid.toString() ,
157158 sent.toSat(),
158159 received.toSat(),
159160 fee?.toSat() ? : 0uL ,
@@ -179,6 +180,8 @@ class Wallet private constructor(
179180
180181 fun getNewAddress (): AddressInfo = wallet.revealNextAddress(KeychainKind .EXTERNAL )
181182
183+ fun getLastCheckpoint (): BlockId = wallet.latestCheckpoint();
184+
182185 fun startKyotoNode () {
183186 Log .i(TAG , " Starting Kyoto node" )
184187 // val ip: IpAddress = IpAddress.fromIpv4(68u, 47u, 229u, 218u) // Signet
@@ -192,7 +195,7 @@ class Wallet private constructor(
192195 .dataDir(this .internalAppFilesPath)
193196 .peers(peers)
194197 .connections(1u )
195- .scanType(ScanType .New )
198+ .scanType(ScanType .Sync )
196199 .build(this .wallet)
197200
198201 node.run ()
@@ -232,7 +235,7 @@ class Wallet private constructor(
232235 KeychainKind .INTERNAL ,
233236 )
234237 val walletId = UUID .randomUUID().toString()
235- val connection = Connection (" $internalAppFilesPath /wallet-${walletId.take(8 )} .sqlite3" )
238+ val connection = Persister .newSqlite (" $internalAppFilesPath /wallet-${walletId.take(8 )} .sqlite3" )
236239
237240 // Create SingleWallet object for saving to datastore
238241 val newWalletForDatastore: SingleWallet =
@@ -256,7 +259,7 @@ class Wallet private constructor(
256259 descriptor = descriptor,
257260 changeDescriptor = changeDescriptor,
258261 network = newWalletConfig.network,
259- connection = connection,
262+ persister = connection,
260263 )
261264
262265 val walletSecrets = WalletSecrets (descriptor, changeDescriptor, mnemonic.toString())
@@ -280,12 +283,12 @@ class Wallet private constructor(
280283 ): Wallet {
281284 val descriptor = Descriptor (activeWallet.descriptor, activeWallet.network.intoDomain())
282285 val changeDescriptor = Descriptor (activeWallet.changeDescriptor, activeWallet.network.intoDomain())
283- val connection = Connection (" $internalAppFilesPath /wallet-${activeWallet.id.take(8 )} .sqlite3" )
286+ val connection = Persister .newSqlite (" $internalAppFilesPath /wallet-${activeWallet.id.take(8 )} .sqlite3" )
284287 val bdkWallet =
285288 BdkWallet .load(
286289 descriptor = descriptor,
287290 changeDescriptor = changeDescriptor,
288- connection = connection,
291+ persister = connection,
289292 )
290293
291294 val walletSecrets = WalletSecrets (descriptor, changeDescriptor, activeWallet.recoveryPhrase)
@@ -337,7 +340,7 @@ class Wallet private constructor(
337340 changeDescriptor = recoverWalletConfig.changeDescriptor
338341 }
339342 val walletId = UUID .randomUUID().toString()
340- val connection = Connection (" $internalAppFilesPath /wallet-${walletId.take(8 )} .sqlite3" )
343+ val connection = Persister .newSqlite (" $internalAppFilesPath /wallet-${walletId.take(8 )} .sqlite3" )
341344
342345 // Create SingleWallet object for saving to datastore
343346 val newWalletForDatastore: SingleWallet =
@@ -360,7 +363,7 @@ class Wallet private constructor(
360363 BdkWallet (
361364 descriptor = descriptor,
362365 changeDescriptor = changeDescriptor,
363- connection = connection,
366+ persister = connection,
364367 network = recoverWalletConfig.network,
365368 )
366369
0 commit comments