Skip to content

Commit ae0f3b8

Browse files
bincode serialization
1 parent 5d0493d commit ae0f3b8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

dash/src/hash_types.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,30 @@ use hashes::{sha256, sha256d, hash160, hash_newtype, Hash, hash_newtype_no_ord};
272272
}
273273
}
274274

275+
impl ConfirmedHashHashedWithProRegTx {
276+
/// Create a ConfirmedHash from a string
277+
pub fn from_hex(s: &str) -> Result<ConfirmedHashHashedWithProRegTx, Error> {
278+
Ok(Self(sha256d::Hash::from_str(s)?))
279+
}
280+
281+
/// Convert a ConfirmedHash to a string
282+
pub fn to_hex(&self) -> String {
283+
self.0.to_string()
284+
}
285+
286+
/// Hashes the members
287+
pub fn hash_members(pro_tx_hash: &ProTxHash, confirmed_hash: &ConfirmedHash) -> Self {
288+
Self::hash(&[pro_tx_hash.to_byte_array(), confirmed_hash.to_byte_array()].concat())
289+
}
290+
/// Hashes the members
291+
pub fn hash_members_confirmed_hash_optional(pro_tx_hash: &ProTxHash, confirmed_hash: Option<&ConfirmedHash>) -> Option<Self> {
292+
confirmed_hash.map(|confirmed_hash| {
293+
Self::hash(&[pro_tx_hash.to_byte_array(), confirmed_hash.to_byte_array()].concat())
294+
})
295+
296+
}
297+
}
298+
275299
impl Sha256dHash {
276300
/// Create a Sha256dHash from a string
277301
pub fn from_hex(s: &str) -> Result<Sha256dHash, Error> {

0 commit comments

Comments
 (0)