Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
Fix semver breaking Display change of ChildNumber
Browse files Browse the repository at this point in the history
Fixes rust-bitcoin#608. In rust-bitcoin#567 the Display impl for ChildNumber was
consciously changed, assuming the semver break would not
affect any correctly implemented downstream projects. We
were wrong.
  • Loading branch information
sgeisler authored and tobin-crypto committed Sep 8, 2021
1 parent e655654 commit bb4c507
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/util/bip32.rs
Expand Up @@ -172,7 +172,7 @@ impl fmt::Display for ChildNumber {
ChildNumber::Hardened { index } => {
fmt::Display::fmt(&index, f)?;
let alt = f.alternate();
f.write_str(if alt { "'" } else { "h" })
f.write_str(if alt { "h" } else { "'" })
},
ChildNumber::Normal { index } => fmt::Display::fmt(&index, f),
}
Expand Down Expand Up @@ -1070,10 +1070,10 @@ mod tests {

#[test]
fn fmt_child_number() {
assert_eq!("000005'", &format!("{:#06}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("5'", &format!("{:#}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("000005h", &format!("{:06}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("5h", &format!("{}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("000005h", &format!("{:#06}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("5h", &format!("{:#}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("000005'", &format!("{:06}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("5'", &format!("{}", ChildNumber::from_hardened_idx(5).unwrap()));
assert_eq!("42", &format!("{}", ChildNumber::from_normal_idx(42).unwrap()));
assert_eq!("000042", &format!("{:06}", ChildNumber::from_normal_idx(42).unwrap()));
}
Expand Down

0 comments on commit bb4c507

Please sign in to comment.