From e28d6d42447ec32afaacc62789729c3386004171 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sat, 15 Jun 2024 14:10:51 +0000 Subject: [PATCH] descriptor: drop `to_string_no_chksum` method This method has been made redundant by the `{:#}` display specifier since 7577e8ceda6d7c83be4f4422ec9be39c11f9050c two years ago. It is poorly named, inefficient since it always requires allocating a `String`, and also broken because it uses debug display for keys. All of our unit tests were converted over to use :# which is why it wasn't noticed that this method didn't work. Fixes #34 Fixes #85 --- CHANGELOG.md | 4 ++++ src/descriptor/csfs_cov/mod.rs | 2 +- src/descriptor/mod.rs | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c18e662..7d470d88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Unreleased + +- [Removed `to_string_no_chksum`](https://github.com/ElementsProject/elements-miniscript/pull/86). This method was poorly-named and broken. Use the alternate display `{:#}` formatter instead to format descriptors without a checksum. + # 0.3.1 - May 10, 2024 - [Fixed](https://github.com/ElementsProject/elements-miniscript/pull/81) ELIP-151 hash calculation diff --git a/src/descriptor/csfs_cov/mod.rs b/src/descriptor/csfs_cov/mod.rs index bb96e4a9..683412a9 100644 --- a/src/descriptor/csfs_cov/mod.rs +++ b/src/descriptor/csfs_cov/mod.rs @@ -84,7 +84,7 @@ mod tests { fn string_rtt(desc_str: &str) { let desc = Descriptor::::from_str(desc_str).unwrap(); - assert_eq!(desc.to_string_no_chksum(), desc_str); + assert_eq!(format!("{:#}", desc), desc_str); let cov_desc = desc.as_cov().unwrap(); assert_eq!(cov_desc.to_string(), desc.to_string()); } diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index 2d37aef9..19294b8e 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -434,10 +434,6 @@ impl Descriptor { } } - /// Return a string without the checksum - pub fn to_string_no_chksum(&self) -> String { - format!("{:?}", self) - } /// Checks whether the descriptor is safe. /// /// Checks whether all the spend paths in the descriptor are possible on the