Skip to content

Commit b707586

Browse files
committed
Merge #1930: feat(chain): Add method for constructing TxGraph from a ChangeSet
f68cfa8 feat(chain): Add method for constructing `TxGraph` from a `ChangeSet` (uvuvuwu) Pull request description: ### Description * Added a `from_changeset()` function to `TxGraph` implementation * This function initializes a new `TxGraph` and applies the given `ChangeSet` * The method allows constructing a `TxGraph` directly from a `ChangeSet`, simplifying graph creation. #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [ ] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: evanlinjin: ACK f68cfa8 LagginTimes: ACK f68cfa8 AmosOO7: ACK f68cfa8 Tree-SHA512: 9301bb606cf131e0a9871fad0cfa5b50ccce810717672a68bc5c256bb643b75fa04682b3c22510194c4e278aa56fe467eeeee343ade50c47bfa2713c41a64abf
2 parents 18b7d9c + f68cfa8 commit b707586

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/chain/src/tx_graph.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,13 @@ impl<A: Anchor> TxGraph<A> {
12161216
self.try_list_expected_spk_txids(chain, chain_tip, indexer, spk_index_range)
12171217
.map(|r| r.expect("infallible"))
12181218
}
1219+
1220+
/// Construct a `TxGraph` from a `changeset`.
1221+
pub fn from_changeset(changeset: ChangeSet<A>) -> Self {
1222+
let mut graph = Self::default();
1223+
graph.apply_changeset(changeset);
1224+
graph
1225+
}
12191226
}
12201227

12211228
/// The [`ChangeSet`] represents changes to a [`TxGraph`].

0 commit comments

Comments
 (0)