Skip to main content

pallas_txbuilder/transaction/
mod.rs

1use serde::{Deserialize, Serialize};
2
3pub mod model;
4pub mod serialise;
5
6#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Clone)]
7#[serde(rename_all = "snake_case")]
8pub enum TransactionStatus {
9    #[default]
10    Staging,
11    Built,
12}
13
14/// Fixed-length 32-byte buffer (transaction hashes, datum hashes, public keys).
15#[derive(PartialEq, Eq, Hash, Debug, Clone)]
16pub struct Bytes32(pub [u8; 32]);
17
18#[derive(Hash, PartialEq, Eq, Debug, Clone)]
19pub struct Bytes64(pub [u8; 64]);
20
21type PublicKey = Bytes32;
22type Signature = Bytes64;
23
24#[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
25pub struct Hash28(pub [u8; 28]);
26
27/// Owned variable-length byte buffer used for asset names, datum payloads, etc.
28#[derive(Clone, PartialEq, Eq, Hash, Debug)]
29pub struct Bytes(pub Vec<u8>);
30
31impl From<Bytes> for pallas_codec::utils::Bytes {
32    fn from(value: Bytes) -> Self {
33        value.0.into()
34    }
35}
36
37impl From<Vec<u8>> for Bytes {
38    fn from(value: Vec<u8>) -> Self {
39        Bytes(value)
40    }
41}
42
43impl AsRef<[u8]> for Bytes {
44    fn as_ref(&self) -> &[u8] {
45        &self.0
46    }
47}
48
49pub type TxHash = Bytes32;
50pub type PubKeyHash = Hash28;
51pub type ScriptHash = Hash28;
52pub type ScriptBytes = Bytes;
53pub type PolicyId = ScriptHash;
54pub type DatumHash = Bytes32;
55pub type DatumBytes = Bytes;
56pub type AssetName = Bytes;