You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- fixes the implementation of `GetKey` for `Xprv` with
`KeyRequest::Bip32` and a key_origin information.
- adds a new test for a scenario where no wildcard is used, and an
specific derivation index is used.
if descriptor_xkey.matches(key_source, secp).is_some(){
140
140
let(_, full_path) = key_source;
141
141
142
-
let derivation_path = &full_path[matched_path.len()..];
143
-
144
-
returnOk(Some(
145
-
descriptor_xkey
146
-
.xkey
147
-
.derive_priv(secp,&derivation_path)
148
-
.map_err(GetKeyError::Bip32)?
149
-
.to_priv(),
150
-
));
142
+
match&descriptor_xkey.origin{
143
+
Some((_, origin_path)) => {
144
+
let derivation_path = &full_path[origin_path.len()..];
145
+
returnOk(Some(
146
+
descriptor_xkey
147
+
.xkey
148
+
.derive_priv(secp,&derivation_path)?
149
+
.to_priv(),
150
+
));
151
+
}
152
+
None => {
153
+
returnOk(Some(
154
+
descriptor_xkey
155
+
.xkey
156
+
.derive_priv(secp,&full_path)?
157
+
.to_priv(),
158
+
))
159
+
}
160
+
};
151
161
}
152
162
153
163
Ok(None)
@@ -314,7 +324,7 @@ mod tests {
314
324
}
315
325
316
326
#[test]
317
-
fnget_key_xpriv_with_key_origin(){
327
+
fnget_key_xpriv_with_key_origin_and_wildcard(){
318
328
let secp = Secp256k1::new();
319
329
320
330
let descriptor_str = "wpkh([d34db33f/84h/1h/0h]tprv8ZgxMBicQKsPd3EupYiPRhaMooHKUHJxNsTfYuScep13go8QFfHdtkG9nRkFGb7busX4isf6X9dURGCoKgitaApQ6MupRhZMcELAxTBRJgS/*)";
let descriptor_str = "wpkh([d34db33f/84h/1h/0h]tprv8ZgxMBicQKsPd3EupYiPRhaMooHKUHJxNsTfYuScep13go8QFfHdtkG9nRkFGb7busX4isf6X9dURGCoKgitaApQ6MupRhZMcELAxTBRJgS/0)";
let descriptor_sk = DescriptorSecretKey::from_str("[d34db33f/84h/1h/0h]tprv8ZgxMBicQKsPd3EupYiPRhaMooHKUHJxNsTfYuScep13go8QFfHdtkG9nRkFGb7busX4isf6X9dURGCoKgitaApQ6MupRhZMcELAxTBRJgS/0").unwrap();
0 commit comments