diff --git a/pallas-addresses/src/lib.rs b/pallas-addresses/src/lib.rs index dd1ee11..13271cd 100644 --- a/pallas-addresses/src/lib.rs +++ b/pallas-addresses/src/lib.rs @@ -143,6 +143,20 @@ impl ShelleyPaymentPart { Self::Script(x) => x.to_vec(), } } + + pub fn to_hex(&self) -> String { + let bytes = self.to_vec(); + hex::encode(bytes) + } + + pub fn to_bech32(&self) -> Result { + let hrp = match self { + Self::Key(_) => "addr_vkh", + Self::Script(_) => "addr_shared_vkh" + }; + let bytes = self.to_vec(); + encode_bech32(&bytes, hrp) + } /// Indicates if this is the hash of a script pub fn is_script(&self) -> bool { @@ -191,6 +205,21 @@ impl ShelleyDelegationPart { Self::Null => vec![], } } + + pub fn to_hex(&self) -> String { + let bytes = self.to_vec(); + hex::encode(bytes) + } + + pub fn to_bech32(&self) -> Result { + let hrp = match self { + Self::Key(_) => "stake_vkh", + Self::Script(_) => "stake_shared_vkh", + _ => todo!(), + }; + let bytes = self.to_vec(); + encode_bech32(&bytes, hrp) + } pub fn is_script(&self) -> bool { matches!(self, ShelleyDelegationPart::Script(_))