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(){
77
79
let(_, full_path) = key_source;
78
80
79
-
let derivation_path = &full_path[matched_path.len()..];
80
-
81
-
returnOk(Some(
82
-
descriptor_xkey
83
-
.xkey
84
-
.derive_priv(secp,&derivation_path)
85
-
.map_err(GetKeyError::Bip32)?
86
-
.to_priv(),
87
-
));
81
+
match&descriptor_xkey.origin{
82
+
Some((_, origin_path)) => {
83
+
let derivation_path = &full_path[origin_path.len()..];
84
+
returnOk(Some(
85
+
descriptor_xkey
86
+
.xkey
87
+
.derive_priv(secp,&derivation_path)?
88
+
.to_priv(),
89
+
));
90
+
}
91
+
None => {
92
+
returnOk(Some(
93
+
descriptor_xkey
94
+
.xkey
95
+
.derive_priv(secp,&full_path)?
96
+
.to_priv(),
97
+
))
98
+
}
99
+
};
88
100
}
89
101
90
102
Ok(None)
@@ -255,7 +267,7 @@ mod tests {
255
267
}
256
268
257
269
#[test]
258
-
fnget_key_xpriv_with_key_origin(){
270
+
fnget_key_xpriv_with_key_origin_and_wildcard(){
259
271
let secp = Secp256k1::new();
260
272
261
273
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