Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,11 @@ where
&self.secp
}

/// Checks if the wallet has internal descriptor
pub fn has_internal_descriptor(&self) -> bool {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think has_descriptor_for_keychain(&self, keychain: KeychainKind) would be better. I have in my mind to add other KeychainKinds later on and this would be helpful to that end.

self.change_descriptor.is_some()
}

/// Returns the descriptor used to create addresses for a particular `keychain`.
pub fn get_descriptor_for_keychain(&self, keychain: KeychainKind) -> &ExtendedDescriptor {
let (descriptor, _) = self._get_descriptor_for_keychain(keychain);
Expand Down Expand Up @@ -4005,6 +4010,17 @@ pub(crate) mod test {
builder.add_recipient(addr.script_pubkey(), 45_000);
builder.finish().unwrap();
}

#[test]
fn test_has_internal_descriptor() {
let db = MemoryDatabase::new();
let wallet = Wallet::new_offline("wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)",
None, Network::Testnet, db).unwrap();

assert_eq!(
wallet.has_internal_descriptor(), false
);
}
}

/// Deterministically generate a unique name given the descriptors defining the wallet
Expand Down