@@ -63,6 +63,14 @@ impl<Pk: MiniscriptKey> Wsh<Pk> {
6363 pub fn as_inner ( & self ) -> & WshInner < Pk > {
6464 & self . inner
6565 }
66+
67+ /// Get the descriptor without the checksum
68+ pub fn to_string_no_checksum ( & self ) -> String {
69+ match self . inner {
70+ WshInner :: SortedMulti ( ref smv) => format ! ( "wsh({})" , smv) ,
71+ WshInner :: Ms ( ref ms) => format ! ( "wsh({})" , ms) ,
72+ }
73+ }
6674}
6775
6876/// Wsh Inner
@@ -123,10 +131,7 @@ impl<Pk: MiniscriptKey> fmt::Debug for Wsh<Pk> {
123131
124132impl < Pk : MiniscriptKey > fmt:: Display for Wsh < Pk > {
125133 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
126- let desc = match self . inner {
127- WshInner :: SortedMulti ( ref smv) => format ! ( "wsh({})" , smv) ,
128- WshInner :: Ms ( ref ms) => format ! ( "wsh({})" , ms) ,
129- } ;
134+ let desc = self . to_string_no_checksum ( ) ;
130135 let checksum = desc_checksum ( & desc) . map_err ( |_| fmt:: Error ) ?;
131136 write ! ( f, "{}#{}" , & desc, & checksum)
132137 }
@@ -293,6 +298,11 @@ impl<Pk: MiniscriptKey> Wpkh<Pk> {
293298 pub fn as_inner ( & self ) -> & Pk {
294299 & self . pk
295300 }
301+
302+ /// Get the descriptor without the checksum
303+ pub fn to_string_no_checksum ( & self ) -> String {
304+ format ! ( "wpkh({})" , self . pk)
305+ }
296306}
297307
298308impl < Pk : MiniscriptKey > fmt:: Debug for Wpkh < Pk > {
@@ -303,7 +313,7 @@ impl<Pk: MiniscriptKey> fmt::Debug for Wpkh<Pk> {
303313
304314impl < Pk : MiniscriptKey > fmt:: Display for Wpkh < Pk > {
305315 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
306- let desc = format ! ( "wpkh({})" , self . pk ) ;
316+ let desc = self . to_string_no_checksum ( ) ;
307317 let checksum = desc_checksum ( & desc) . map_err ( |_| fmt:: Error ) ?;
308318 write ! ( f, "{}#{}" , & desc, & checksum)
309319 }
0 commit comments