Skip to content

Commit 2684570

Browse files
committed
fix Display impl for ct desc
1 parent 589e67c commit 2684570

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/confidential/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::fmt;
2626
use bitcoin::bip32;
2727
use elements::secp256k1_zkp;
2828

29-
use crate::descriptor::checksum::{desc_checksum, verify_checksum};
29+
use crate::descriptor::checksum::{self, verify_checksum};
3030
use crate::descriptor::{
3131
ConversionError, DefiniteDescriptorKey, DescriptorSecretKey, DescriptorPublicKey,
3232
DescriptorXKey, Wildcard
@@ -189,9 +189,10 @@ impl<Pk: MiniscriptKey + ToPublicKey, T: Extension + ParseableExt> Descriptor<Pk
189189

190190
impl<Pk: MiniscriptKey, T: Extension> fmt::Display for Descriptor<Pk, T> {
191191
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
192-
let desc_str = format!("ct({},{:#})", self.key, self.descriptor);
193-
let checksum = desc_checksum(&desc_str).map_err(|_| fmt::Error)?;
194-
write!(f, "{}#{}", desc_str, checksum)
192+
use fmt::Write;
193+
let mut wrapped_f = checksum::Formatter::new(f);
194+
write!(wrapped_f, "ct({},{:#})", self.key, self.descriptor)?;
195+
wrapped_f.write_checksum_if_not_alt()
195196
}
196197
}
197198

0 commit comments

Comments
 (0)