Skip to content

Commit b8aa76c

Browse files
evanlinjinnotmandatory
authored andcommitted
feat(wallet): use the new CombinedChangeSet of bdk_persist
1 parent 0958ff5 commit b8aa76c

File tree

2 files changed

+3
-68
lines changed

2 files changed

+3
-68
lines changed

crates/wallet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bitcoin = { version = "0.31.0", features = ["serde", "base64", "rand-std"], defa
2020
serde = { version = "^1.0", features = ["derive"] }
2121
serde_json = { version = "^1.0" }
2222
bdk_chain = { path = "../chain", version = "0.14.0", features = ["miniscript", "serde"], default-features = false }
23-
bdk_persist = { path = "../persist", version = "0.2.0" }
23+
bdk_persist = { path = "../persist", version = "0.2.0", features = ["miniscript", "serde"], default-features = false }
2424

2525
# Optional dependencies
2626
bip39 = { version = "2.0", optional = true }

crates/wallet/src/wallet/mod.rs

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use alloc::{
2222
pub use bdk_chain::keychain::Balance;
2323
use bdk_chain::{
2424
indexed_tx_graph,
25-
keychain::{self, KeychainTxOutIndex},
25+
keychain::KeychainTxOutIndex,
2626
local_chain::{
2727
self, ApplyHeaderError, CannotConnectError, CheckPoint, CheckPointIter, LocalChain,
2828
},
@@ -134,72 +134,7 @@ impl From<SyncResult> for Update {
134134
}
135135

136136
/// The changes made to a wallet by applying an [`Update`].
137-
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
138-
pub struct ChangeSet {
139-
/// Changes to the [`LocalChain`].
140-
///
141-
/// [`LocalChain`]: local_chain::LocalChain
142-
pub chain: local_chain::ChangeSet,
143-
144-
/// Changes to [`IndexedTxGraph`].
145-
///
146-
/// [`IndexedTxGraph`]: bdk_chain::indexed_tx_graph::IndexedTxGraph
147-
pub indexed_tx_graph: indexed_tx_graph::ChangeSet<
148-
ConfirmationTimeHeightAnchor,
149-
keychain::ChangeSet<KeychainKind>,
150-
>,
151-
152-
/// Stores the network type of the wallet.
153-
pub network: Option<Network>,
154-
}
155-
156-
impl Append for ChangeSet {
157-
fn append(&mut self, other: Self) {
158-
Append::append(&mut self.chain, other.chain);
159-
Append::append(&mut self.indexed_tx_graph, other.indexed_tx_graph);
160-
if other.network.is_some() {
161-
debug_assert!(
162-
self.network.is_none() || self.network == other.network,
163-
"network type must be consistent"
164-
);
165-
self.network = other.network;
166-
}
167-
}
168-
169-
fn is_empty(&self) -> bool {
170-
self.chain.is_empty() && self.indexed_tx_graph.is_empty()
171-
}
172-
}
173-
174-
impl From<local_chain::ChangeSet> for ChangeSet {
175-
fn from(chain: local_chain::ChangeSet) -> Self {
176-
Self {
177-
chain,
178-
..Default::default()
179-
}
180-
}
181-
}
182-
183-
impl
184-
From<
185-
indexed_tx_graph::ChangeSet<
186-
ConfirmationTimeHeightAnchor,
187-
keychain::ChangeSet<KeychainKind>,
188-
>,
189-
> for ChangeSet
190-
{
191-
fn from(
192-
indexed_tx_graph: indexed_tx_graph::ChangeSet<
193-
ConfirmationTimeHeightAnchor,
194-
keychain::ChangeSet<KeychainKind>,
195-
>,
196-
) -> Self {
197-
Self {
198-
indexed_tx_graph,
199-
..Default::default()
200-
}
201-
}
202-
}
137+
pub type ChangeSet = bdk_persist::CombinedChangeSet<KeychainKind, ConfirmationTimeHeightAnchor>;
203138

204139
/// A derived address and the index it was found at.
205140
/// For convenience this automatically derefs to `Address`

0 commit comments

Comments
 (0)