I accidentally found out that if you try to build a Descriptor with DescriptorXKey and hardened derivation path, the at_derivation_index panics with The key should not contain any wildcards at this point.
use bitcoin::{
bip32::{ChildNumber, DerivationPath, Xpriv, Xpub},
Network,
};
use miniscript::{
descriptor::{DescriptorXKey, Wildcard},
Descriptor, DescriptorPublicKey,
};
fn main() {
let xpriv = Xpriv::new_master(Network::Regtest, &[1u8; 256]).unwrap();
let desc =
Descriptor::<DescriptorPublicKey>::new_pkh(DescriptorPublicKey::XPub(DescriptorXKey {
origin: None,
xkey: Xpub::from_priv(&secp256k1::Secp256k1::new(), &xpriv),
derivation_path: DerivationPath::from_iter([ChildNumber::Hardened { index: 1 }]),
wildcard: Wildcard::Unhardened,
}))
.unwrap();
desc.at_derivation_index(1).unwrap(); // panics because of .expect() inside
}
It makes sense that the function "fails", because at this point at_derivation_index can't derive a descriptor, but the message seems internal and misleading regarding the true cause. I expected it to return an error
I accidentally found out that if you try to build a
DescriptorwithDescriptorXKeyand hardened derivation path, theat_derivation_indexpanics withThe key should not contain any wildcards at this point.It makes sense that the function "fails", because at this point
at_derivation_indexcan't derive a descriptor, but the message seems internal and misleading regarding the true cause. I expected it to return an error