diff --git a/crates/core/src/spk_client.rs b/crates/core/src/spk_client.rs
index b6a8e0204..5f3cef430 100644
--- a/crates/core/src/spk_client.rs
+++ b/crates/core/src/spk_client.rs
@@ -403,6 +403,13 @@ impl Default for SyncResponse {
}
}
+impl SyncResponse {
+ /// Returns true if the `SyncResponse` is empty.
+ pub fn is_empty(&self) -> bool {
+ self.tx_update.is_empty() && self.chain_update.is_none()
+ }
+}
+
/// Builds a [`FullScanRequest`].
///
/// Construct with [`FullScanRequest::builder`].
@@ -560,6 +567,15 @@ impl Default for FullScanResponse {
}
}
+impl FullScanResponse {
+ /// Returns true if the `FullScanResponse` is empty.
+ pub fn is_empty(&self) -> bool {
+ self.tx_update.is_empty()
+ && self.last_active_indices.is_empty()
+ && self.chain_update.is_none()
+ }
+}
+
struct KeychainSpkIter<'r, K> {
keychain: K,
spks: Option<&'r mut Box> + Send>>,
diff --git a/crates/core/src/tx_update.rs b/crates/core/src/tx_update.rs
index 89a224fbd..9be91f1ba 100644
--- a/crates/core/src/tx_update.rs
+++ b/crates/core/src/tx_update.rs
@@ -64,6 +64,17 @@ impl Default for TxUpdate {
}
}
+impl TxUpdate {
+ /// Returns true if the `TxUpdate` contains no elements in any of its fields.
+ pub fn is_empty(&self) -> bool {
+ self.txs.is_empty()
+ && self.txouts.is_empty()
+ && self.anchors.is_empty()
+ && self.seen_ats.is_empty()
+ && self.evicted_ats.is_empty()
+ }
+}
+
impl TxUpdate {
/// Transforms the [`TxUpdate`] to have `anchors` (`A`) of another type (`A2`).
///
diff --git a/crates/core/tests/test_spk_client.rs b/crates/core/tests/test_spk_client.rs
new file mode 100644
index 000000000..38766ac31
--- /dev/null
+++ b/crates/core/tests/test_spk_client.rs
@@ -0,0 +1,13 @@
+use bdk_core::spk_client::{FullScanResponse, SyncResponse};
+
+#[test]
+fn test_empty() {
+ assert!(
+ FullScanResponse::<(), ()>::default().is_empty(),
+ "Default `FullScanResponse` must be empty"
+ );
+ assert!(
+ SyncResponse::<()>::default().is_empty(),
+ "Default `SyncResponse` must be empty"
+ );
+}
diff --git a/crates/core/tests/test_tx_update.rs b/crates/core/tests/test_tx_update.rs
new file mode 100644
index 000000000..d5d2dbc3b
--- /dev/null
+++ b/crates/core/tests/test_tx_update.rs
@@ -0,0 +1,9 @@
+use bdk_core::TxUpdate;
+
+#[test]
+fn test_empty() {
+ assert!(
+ TxUpdate::<()>::default().is_empty(),
+ "Default `TxUpdate` must be empty"
+ );
+}