Skip to content

Commit c7977d1

Browse files
Determine parent or child wallet from the Fingerprint
1 parent cecbe9a commit c7977d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/core/bip32/primitives.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ impl From<[u8; 4]> for KeyFingerprint {
2424
}
2525

2626
impl KeyFingerprint {
27+
pub fn is_zero(&self) -> bool {
28+
self.0.iter().all(|b| *b == 0)
29+
}
30+
2731
/// Determines if the slice represents the same key fingerprint
2832
pub fn eq_slice(self, other: &[u8]) -> bool {
2933
self.0 == other

src/core/user/wallet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Wallet {
219219
}
220220

221221
pub fn is_master(&self) -> bool {
222-
self.xkey_info.as_ref().map(|info| info.index == 0).unwrap_or(false)
222+
self.xkey_info.as_ref().map(|info| info.parent.is_zero()).unwrap_or(false)
223223
}
224224

225225
pub fn is_hardened(&self) -> bool {

0 commit comments

Comments
 (0)