1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use core::ops::Deref;
use crate::payload::milestone::MilestoneId;
impl_id!(
pub TransactionId,
32,
"A transaction identifier, the BLAKE2b-256 hash of the transaction bytes. See <https://www.blake2.net/> for more information."
);
#[cfg(feature = "serde")]
string_serde_impl!(TransactionId);
impl From<MilestoneId> for TransactionId {
fn from(milestone_id: MilestoneId) -> Self {
Self::new(*milestone_id.deref())
}
}
#[cfg(feature = "inx")]
mod inx {
use super::*;
impl From<TransactionId> for ::inx::proto::TransactionId {
fn from(value: TransactionId) -> Self {
Self { id: value.0.to_vec() }
}
}
impl TryFrom<::inx::proto::TransactionId> for TransactionId {
type Error = crate::error::inx::InxError;
fn try_from(value: ::inx::proto::TransactionId) -> Result<Self, Self::Error> {
let bytes: [u8; TransactionId::LENGTH] = value
.id
.try_into()
.map_err(|e| Self::Error::InvalidId("TransactionId", e))?;
Ok(TransactionId::from(bytes))
}
}
}