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