Trait reef::traits::Transaction
source · pub trait Transaction: Clone + Debug + Serialize + DeserializeOwned + Send + Sync {
type NullifierSet: NullifierSet;
type Hash: Clone + Debug + Eq + Hash + Send + Sync + Serialize + DeserializeOwned + CanonicalSerialize + CanonicalDeserialize;
type Kind: TransactionKind;
// Required methods
fn cap(
note: TransactionNote,
proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof>
) -> Self;
fn open_viewing_memo(
&self,
viewable_assets: &HashMap<AssetCode, AssetDefinition>,
viewing_keys: &HashMap<ViewerPubKey, ViewerKeyPair>
) -> Result<ViewingMemoOpening, ViewingError>;
fn proven_nullifiers(
&self
) -> Vec<(Nullifier, <Self::NullifierSet as NullifierSet>::Proof)>;
fn output_commitments(&self) -> Vec<RecordCommitment>;
fn hash(&self) -> Self::Hash;
fn kind(&self) -> Self::Kind;
fn set_proofs(
&mut self,
proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof>
);
// Provided methods
fn output_openings(&self) -> Option<Vec<RecordOpening>> { ... }
fn output_len(&self) -> usize { ... }
fn input_nullifiers(&self) -> Vec<Nullifier> { ... }
}Expand description
A CAP transaction.
A CAP transaction is an operation on the CAP ledger – it consumes a set of records, adding their nullifiers to the nullifier set, and produces a list of new records, adding their commitments to the record set. It may also contain viewing information encrypted under the viewing key of the transaction’s asset type.
The transaction may also contain information specific to a particular instantiation of CAP, such as a proof that the transaction is valid, bookkeeping related to fees and rewards, or optional plaintext record openings for the transaction outputs, in the case of a non-private type of transaction.
Regardless of the exact structure of the transaction, this interface captures the transaction’s effects on the ledger when it is executed – the exact nullifiers and record commitments which will be added to the ledger, regardless of how they are encoded in the transaction.
Required Associated Types§
sourcetype NullifierSet: NullifierSet
type NullifierSet: NullifierSet
Nullifier set to be updated when a transaction is added to the ledger.
sourcetype Hash: Clone + Debug + Eq + Hash + Send + Sync + Serialize + DeserializeOwned + CanonicalSerialize + CanonicalDeserialize
type Hash: Clone + Debug + Eq + Hash + Send + Sync + Serialize + DeserializeOwned + CanonicalSerialize + CanonicalDeserialize
Transaction digest.
This should be a determinstic, injective, committing function of the transaction.
sourcetype Kind: TransactionKind
type Kind: TransactionKind
Supported transaction types.
Required Methods§
sourcefn cap(
note: TransactionNote,
proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof>
) -> Self
fn cap( note: TransactionNote, proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof> ) -> Self
Wrap a raw CAP transaction in this network’s transaction type.
sourcefn open_viewing_memo(
&self,
viewable_assets: &HashMap<AssetCode, AssetDefinition>,
viewing_keys: &HashMap<ViewerPubKey, ViewerKeyPair>
) -> Result<ViewingMemoOpening, ViewingError>
fn open_viewing_memo( &self, viewable_assets: &HashMap<AssetCode, AssetDefinition>, viewing_keys: &HashMap<ViewerPubKey, ViewerKeyPair> ) -> Result<ViewingMemoOpening, ViewingError>
Attempt to decrypt the attached viewing memo.
Given a collection of asset types for which the caller holds the viewing key, attempt to open the viewing memos attached to this transaction.
viewable_assets should be the set of asset types which the caller can view, indexed by
asset code. This determines which asset types can be viewed by this method. viewing_keys
is the caller’s collection of viewing key pairs, indexed by public key. viewing_keys must
contain every public key which is listed as a viewer in the policy of one of the
viewable_assets.
sourcefn proven_nullifiers(
&self
) -> Vec<(Nullifier, <Self::NullifierSet as NullifierSet>::Proof)>
fn proven_nullifiers( &self ) -> Vec<(Nullifier, <Self::NullifierSet as NullifierSet>::Proof)>
Nullifiers for the records that this transaction will consume when executed.
The results should contain authentication that the nullifiers were unspent at the time the transaction was constructed.
sourcefn output_commitments(&self) -> Vec<RecordCommitment>
fn output_commitments(&self) -> Vec<RecordCommitment>
Commitments to the records that this transaction will create when executed.
sourcefn set_proofs(
&mut self,
proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof>
)
fn set_proofs( &mut self, proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof> )
Update the proofs that this transaction’s nullifiers are unspent.
Provided Methods§
sourcefn output_openings(&self) -> Option<Vec<RecordOpening>>
fn output_openings(&self) -> Option<Vec<RecordOpening>>
If this is not a private transaction, get the openings of its output records.
The implementation must ensure that if self.output_openings().is_some(), then
self.output_commitments() is a list of the commitments of each [RecordOpening] in
self.output_openings().unwrap().
sourcefn output_len(&self) -> usize
fn output_len(&self) -> usize
The number of outputs.
This is equivalent to self.output_commitments().len(), but may be more efficient in some
implementations.
sourcefn input_nullifiers(&self) -> Vec<Nullifier>
fn input_nullifiers(&self) -> Vec<Nullifier>
This transaction’s inputs, without authentication.