Skip to content

Commit b82acb5

Browse files
authored
feat(kyoto)!: update to latest version
1 parent 14cdff5 commit b82acb5

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed

bdk-ffi/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bdk-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bdk_wallet = { version = "1.2.0", features = ["all-keys", "keys-bip39", "rusqlit
2222
bdk_core = { version = "0.4.1" }
2323
bdk_esplora = { version = "0.20.1", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] }
2424
bdk_electrum = { version = "0.21.0", default-features = false, features = ["use-rustls-ring"] }
25-
bdk_kyoto = { version = "0.9.0" }
25+
bdk_kyoto = { version = "0.10.0" }
2626

2727
uniffi = { version = "=0.29.1" }
2828
thiserror = "1.0.58"

bdk-ffi/src/kyoto.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,15 @@ impl CbfClient {
265265

266266
/// Return an [`Update`]. This is method returns once the node syncs to the rest of
267267
/// the network or a new block has been gossiped.
268-
pub async fn update(&self) -> Arc<Update> {
269-
let update = self.update_rx.lock().await.update().await;
270-
Arc::new(Update(update))
268+
pub async fn update(&self) -> Result<Update, CbfError> {
269+
let update = self
270+
.update_rx
271+
.lock()
272+
.await
273+
.update()
274+
.await
275+
.map_err(|_| CbfError::NodeStopped)?;
276+
Ok(Update(update))
271277
}
272278

273279
/// Add scripts for the node to watch for as they are revealed. Typically used after creating
@@ -318,6 +324,8 @@ impl CbfClient {
318324
pub enum Info {
319325
/// All the required connections have been met. This is subject to change.
320326
ConnectionsMet,
327+
/// The node was able to successfully connect to a remote peer.
328+
SuccessfulHandshake,
321329
/// A percentage value of filters that have been scanned.
322330
Progress { progress: f32 },
323331
/// A state in the node syncing process.
@@ -331,6 +339,7 @@ impl From<bdk_kyoto::Info> for Info {
331339
fn from(value: bdk_kyoto::Info) -> Info {
332340
match value {
333341
bdk_kyoto::Info::ConnectionsMet => Info::ConnectionsMet,
342+
bdk_kyoto::Info::SuccessfulHandshake => Info::SuccessfulHandshake,
334343
bdk_kyoto::Info::Progress(progress) => Info::Progress {
335344
progress: progress.percentage_complete(),
336345
},
@@ -365,7 +374,7 @@ pub enum Warning {
365374
CorruptedHeaders,
366375
/// A transaction got rejected, likely for being an insufficient fee or non-standard transaction.
367376
TransactionRejected {
368-
txid: String,
377+
wtxid: String,
369378
reason: Option<String>,
370379
},
371380
/// A database failed to persist some data and may retry again
@@ -397,7 +406,7 @@ impl From<Warn> for Warning {
397406
Warn::TransactionRejected { payload } => {
398407
let reason = payload.reason.map(|r| r.into_string());
399408
Warning::TransactionRejected {
400-
txid: payload.txid.to_string(),
409+
wtxid: payload.wtxid.to_string(),
401410
reason,
402411
}
403412
}

bdk-python/tests/test_live_kyoto.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from bdkpython import Connection, Network, Descriptor, KeychainKind, CbfBuilder, CbfComponents, CbfClient, CbfNode, IpAddress, ScanType, Peer, Update, Wallet
1+
from bdkpython import Connection, Network, Descriptor, KeychainKind, CbfBuilder, CbfComponents, CbfClient, CbfNode, CbfError, IpAddress, ScanType, Peer, Update, Wallet
22
import unittest
33
import os
44
import asyncio
@@ -45,15 +45,18 @@ async def log_loop(client: CbfClient):
4545
print(log)
4646
log_task = asyncio.create_task(log_loop(client))
4747
node.run()
48-
update: Update = await client.update()
49-
wallet.apply_update(update)
50-
self.assertGreater(
51-
wallet.balance().total.to_sat(),
52-
0,
53-
f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(KeychainKind.EXTERNAL).address} and try again."
54-
)
55-
log_task.cancel()
56-
await client.shutdown()
48+
try:
49+
update: Update = await client.update()
50+
wallet.apply_update(update)
51+
self.assertGreater(
52+
wallet.balance().total.to_sat(),
53+
0,
54+
f"Wallet balance must be greater than 0! Please send funds to {wallet.reveal_next_address(KeychainKind.EXTERNAL).address} and try again."
55+
)
56+
log_task.cancel()
57+
client.shutdown()
58+
except CbfError as e:
59+
raise e
5760

5861
if __name__ == "__main__":
5962
unittest.main()

bdk-swift/Tests/BitcoinDevKitTests/LiveKyotoTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class LiveKyotoTests: XCTestCase {
4545
}
4646
}
4747
}
48-
let update = await client.update()
48+
let update = try await client.update()
4949
try wallet.applyUpdate(update: update)
5050
let address = wallet.revealNextAddress(keychain: KeychainKind.external).address.description
5151
XCTAssertGreaterThan(

0 commit comments

Comments
 (0)