Describe the enhancement
- The
public_descriptor function returns a reference to an ExtendedDescriptor, similar to get_descriptor on KeychainTxOutIndex, which returns an Option<Descriptor<DescriptorPublicKey>>
|
pub fn public_descriptor(&self, keychain: KeychainKind) -> &ExtendedDescriptor { |
|
pub fn get_descriptor(&self, keychain: &K) -> Option<&Descriptor<DescriptorPublicKey>> { |
Currently, public_descriptor finds the descriptor from scratch. Instead, it can directly call get_descriptor to simplify its implementation.
pub fn public_descriptor(..) -> &ExtendedDescriptor {
match self.indexed_graph.index.get_descriptor {
// implementation
}
}
- Additionally, the
get_descriptor_for_keychain function is essentially a wrapper around public_descriptor:
|
pub fn get_descriptor_for_keychain(&self, keychain: KeychainKind) -> &ExtendedDescriptor { |
.
Both functions logically serve the same purpose:
public_descriptor: Returns the public version of the descriptor.
get_descriptor_for_keychain: Returns the descriptor used to create addresses for a specific keychain
Therefore, we can eliminate get_descriptor_for_keychain and include its documentation in public_descriptor.
This change will reduce redundancy in Wallet API's.
Use case
- Reduce redundancy in the API.
- Simplify the implementation of public_descriptor.
Describe the enhancement
public_descriptorfunction returns a reference to anExtendedDescriptor, similar toget_descriptoronKeychainTxOutIndex, which returns anOption<Descriptor<DescriptorPublicKey>>bdk/crates/wallet/src/wallet/mod.rs
Line 1770 in a112b4d
bdk/crates/chain/src/keychain/txout_index.rs
Line 407 in a112b4d
Currently,
public_descriptorfinds the descriptor from scratch. Instead, it can directly callget_descriptorto simplify its implementation.get_descriptor_for_keychainfunction is essentially a wrapper aroundpublic_descriptor:bdk/crates/wallet/src/wallet/mod.rs
Line 1882 in a112b4d
Both functions logically serve the same purpose:
public_descriptor: Returns the public version of the descriptor.get_descriptor_for_keychain: Returns the descriptor used to create addresses for a specific keychainTherefore, we can eliminate
get_descriptor_for_keychainand include its documentation inpublic_descriptor.This change will reduce redundancy in Wallet API's.
Use case