Skip to content
Open
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
18 changes: 13 additions & 5 deletions src/descriptor/key_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ impl GetKey for DescriptorSecretKey {
return Ok(Some(key));
}

if descriptor_xkey.matches(key_source, secp).is_some() {
let (_, derivation_path) = key_source;
if let Some(matched_path) = descriptor_xkey.matches(key_source, secp) {
let (_, full_path) = key_source;

let derivation_path = &full_path[matched_path.len()..];

return Ok(Some(
descriptor_xkey
.xkey
Expand Down Expand Up @@ -265,11 +268,16 @@ mod tests {
_ => unreachable!(),
};

let path = DerivationPath::from_str("84'/1'/0'/0").unwrap();
let expected_pk = xpriv.xkey.derive_priv(&secp, &path).unwrap().to_priv();
let expected_deriv_path: DerivationPath = (&[ChildNumber::Normal { index: 0 }][..]).into();
let expected_pk = xpriv
.xkey
.derive_priv(&secp, &expected_deriv_path)
.unwrap()
.to_priv();

let derivation_path = DerivationPath::from_str("84'/1'/0'/0").unwrap();
let (fp, _) = xpriv.origin.unwrap();
let key_request = KeyRequest::Bip32((fp, path));
let key_request = KeyRequest::Bip32((fp, derivation_path));

let pk = keymap_wrapper
.get_key(key_request, &secp)
Expand Down
Loading