Skip to content

Commit 9a93134

Browse files
committed
fix Display impl for legacy pegin
1 parent f77fa62 commit 9a93134

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/descriptor/pegin/legacy_pegin.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use bitcoin::{self, hashes, ScriptBuf as BtcScript};
3434
use bitcoin_miniscript::TranslatePk as BtcTranslatePk;
3535
use elements::secp256k1_zkp;
3636

37-
use crate::descriptor::checksum::{desc_checksum, verify_checksum};
37+
use crate::descriptor::checksum::{self, verify_checksum};
3838
use crate::expression::{self, FromTree};
3939
use crate::extensions::{CovExtArgs, CovenantExt};
4040
use crate::policy::{semantic, Liftable};
@@ -326,9 +326,10 @@ impl<Pk: MiniscriptKey> fmt::Debug for LegacyPegin<Pk> {
326326

327327
impl<Pk: MiniscriptKey> fmt::Display for LegacyPegin<Pk> {
328328
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
329-
let desc = format!("legacy_pegin({},{})", self.ms, self.desc);
330-
let checksum = desc_checksum(&desc).map_err(|_| fmt::Error)?;
331-
write!(f, "{}#{}", &desc, &checksum)
329+
use fmt::Write;
330+
let mut wrapped_f = checksum::Formatter::new(f);
331+
write!(wrapped_f, "legacy_pegin({},{})", self.ms, self.desc)?;
332+
wrapped_f.write_checksum_if_not_alt()
332333
}
333334
}
334335

0 commit comments

Comments
 (0)