Skip to content

Commit b69c61f

Browse files
feat: Stage WalletChangeSet and mutable local_chain and indexed_tx_graph
1 parent fd4e71e commit b69c61f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

crates/bdk/src/wallet/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,11 +1846,25 @@ impl<D> Wallet<D> {
18461846
self.persist.staged()
18471847
}
18481848

1849+
/// Stages wallet changes in memory for later commit.
1850+
///
1851+
/// To commit changes to the persistence backend, call [`commit`].
1852+
///
1853+
/// [`commit`]: Self::commit
1854+
pub fn stage(&mut self, changeset: ChangeSet) where D: PersistBackend<ChangeSet> {
1855+
self.persist.stage(changeset);
1856+
}
1857+
18491858
/// Get a reference to the inner [`TxGraph`].
18501859
pub fn tx_graph(&self) -> &TxGraph<ConfirmationTimeAnchor> {
18511860
self.indexed_graph.graph()
18521861
}
18531862

1863+
/// Get a mutable reference to the inner [`IndexedTxGraph`].
1864+
pub fn mut_indexed_tx_graph(&mut self) -> &mut IndexedTxGraph<ConfirmationTimeAnchor, KeychainTxOutIndex<KeychainKind>> {
1865+
&mut self.indexed_graph
1866+
}
1867+
18541868
/// Get a reference to the inner [`KeychainTxOutIndex`].
18551869
pub fn spk_index(&self) -> &KeychainTxOutIndex<KeychainKind> {
18561870
&self.indexed_graph.index
@@ -1860,6 +1874,11 @@ impl<D> Wallet<D> {
18601874
pub fn local_chain(&self) -> &LocalChain {
18611875
&self.chain
18621876
}
1877+
1878+
/// Get a mutable reference to the inner [`LocalChain`].
1879+
pub fn mut_local_chain(&mut self) -> &mut LocalChain {
1880+
&mut self.chain
1881+
}
18631882
}
18641883

18651884
impl<D> AsRef<bdk_chain::tx_graph::TxGraph<ConfirmationTimeAnchor>> for Wallet<D> {

0 commit comments

Comments
 (0)