radix_transactions/model/v2/
signed_transaction_intent_v2.rs

1use super::*;
2use crate::internal_prelude::*;
3
4//=================================================================================
5// NOTE:
6// See versioned.rs for tests and a demonstration for the calculation of hashes etc
7//=================================================================================
8
9/// A [`SignedTransactionIntentV2`] is an inner model for a [`NotarizedTransactionV2`].
10///
11/// It includes two parts:
12/// * The [`TransactionIntentV2`] which contains a representention of an intent tree
13/// with a root transaction intent, and other subintent descendents. These subintents are
14/// flattened into an array in the model.
15/// * It also includes intent signatures, some for this transaction intent, and separately,
16/// an array of signatures for each each flattened subintents.
17///
18/// ## Similar models
19///
20/// A [`SignedPartialTransactionV2`] is a similar structure for a fully signed partial subtree
21/// of a transaction, but with a subintent root. Whilst useful for constructing a
22/// transaction, it doesn't appear under a [`NotarizedTransactionV2`] because the subintents
23/// get flattened.
24#[derive(Debug, Clone, Eq, PartialEq, ManifestSbor, ScryptoDescribe)]
25pub struct SignedTransactionIntentV2 {
26    pub transaction_intent: TransactionIntentV2,
27    pub transaction_intent_signatures: IntentSignaturesV2,
28    pub non_root_subintent_signatures: NonRootSubintentSignaturesV2,
29}
30
31define_transaction_payload!(
32    SignedTransactionIntentV2,
33    RawSignedTransactionIntent,
34    PreparedSignedTransactionIntentV2 {
35        transaction_intent: PreparedTransactionIntentV2,
36        transaction_intent_signatures: PreparedIntentSignaturesV2,
37        non_root_subintent_signatures: PreparedNonRootSubintentSignaturesV2,
38    },
39    TransactionDiscriminator::V2SignedTransactionIntent,
40);
41
42impl HasTransactionIntentHash for PreparedSignedTransactionIntentV2 {
43    fn transaction_intent_hash(&self) -> TransactionIntentHash {
44        self.transaction_intent.transaction_intent_hash()
45    }
46}
47
48impl HasSignedTransactionIntentHash for PreparedSignedTransactionIntentV2 {
49    fn signed_transaction_intent_hash(&self) -> SignedTransactionIntentHash {
50        SignedTransactionIntentHash::from_hash(self.summary.hash)
51    }
52}
53
54impl HasNonRootSubintentHashes for PreparedSignedTransactionIntentV2 {
55    fn non_root_subintent_hashes(&self) -> Vec<SubintentHash> {
56        self.transaction_intent.non_root_subintent_hashes()
57    }
58}