Skip to content

Commit

Permalink
feat: get keychain that derived a script
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirfomene committed Nov 9, 2023
1 parent 3569acc commit b3d40e5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/bdk/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,14 @@ impl<D> Wallet<D> {
pub fn local_chain(&self) -> &LocalChain {
&self.chain
}

/// Get the [`KeychainKind`] and derivation index for a given [`Script`].
///
/// This will return `None` if the script is not in the wallet.
/// TODO: Generalize this implementation once we make the wallet generic over K
pub fn which_keychain_derived(&self, spk: &Script) -> Option<&(KeychainKind, u32)> {
self.indexed_graph.index.index_of_spk(spk)
}
}

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

0 comments on commit b3d40e5

Please sign in to comment.