Skip to content

Commit ea7170e

Browse files
authored
Merge pull request #265 from darosior/fix_master_fingerprint
2 parents f03261a + 775da51 commit ea7170e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/descriptor/key.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl fmt::Display for ConversionError {
345345
impl error::Error for ConversionError {}
346346

347347
impl DescriptorPublicKey {
348-
/// The fingerprint of the master key associated with this key
348+
/// The fingerprint of the master key associated with this key, `0x00000000` if none.
349349
pub fn master_fingerprint(&self) -> bip32::Fingerprint {
350350
match *self {
351351
DescriptorPublicKey::XPub(ref xpub) => {
@@ -364,7 +364,7 @@ impl DescriptorPublicKey {
364364
.key
365365
.write_into(&mut engine)
366366
.expect("engines don't error");
367-
bip32::Fingerprint::from(&XpubIdentifier::from_engine(engine)[..])
367+
bip32::Fingerprint::from(&XpubIdentifier::from_engine(engine)[..4])
368368
}
369369
}
370370
}
@@ -824,4 +824,17 @@ mod test {
824824
"m/90'/0'/1'/2"
825825
);
826826
}
827+
828+
#[test]
829+
fn test_master_fingerprint() {
830+
assert_eq!(
831+
DescriptorPublicKey::from_str(
832+
"02a489e0ea42b56148d212d325b7c67c6460483ff931c303ea311edfef667c8f35",
833+
)
834+
.unwrap()
835+
.master_fingerprint()
836+
.as_bytes(),
837+
b"\xb0\x59\x11\x6a"
838+
);
839+
}
827840
}

0 commit comments

Comments
 (0)