We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dde7c8b commit 9bc67dfCopy full SHA for 9bc67df
crates/core/src/address.rs
@@ -278,6 +278,20 @@ impl Address {
278
string_encoding::Format::encode(self)
279
}
280
281
+ /// Encode an address in compatibility mode (i.e. with the legacy Bech32
282
+ /// encoding)
283
+ pub fn encode_compat(&self) -> String {
284
+ use crate::string_encoding::Format;
285
+
286
+ bech32::encode::<bech32::Bech32>(Self::HRP, self.to_bytes().as_ref())
287
+ .unwrap_or_else(|_| {
288
+ panic!(
289
+ "The human-readable part {} should never cause a failure",
290
+ Self::HRP
291
+ )
292
+ })
293
+ }
294
295
/// Decode an address from Bech32m encoding
296
pub fn decode(string: impl AsRef<str>) -> Result<Self> {
297
string_encoding::Format::decode(string)
0 commit comments