pub enum Transaction {
Phoenix(Transaction),
Moonlight(Transaction),
}Expand description
The transaction used by the transfer contract.
Variants§
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn phoenix<R: RngCore + CryptoRng, P: Prove>(
rng: &mut R,
sender_sk: &PhoenixSecretKey,
refund_pk: &PhoenixPublicKey,
receiver_pk: &PhoenixPublicKey,
inputs: Vec<(Note, Opening<(), NOTES_TREE_DEPTH>)>,
root: BlsScalar,
transfer_value: u64,
obfuscated_transaction: bool,
deposit: u64,
gas_limit: u64,
gas_price: u64,
chain_id: u8,
data: Option<impl Into<TransactionData>>,
prover: &P,
) -> Result<Self, Error>
pub fn phoenix<R: RngCore + CryptoRng, P: Prove>( rng: &mut R, sender_sk: &PhoenixSecretKey, refund_pk: &PhoenixPublicKey, receiver_pk: &PhoenixPublicKey, inputs: Vec<(Note, Opening<(), NOTES_TREE_DEPTH>)>, root: BlsScalar, transfer_value: u64, obfuscated_transaction: bool, deposit: u64, gas_limit: u64, gas_price: u64, chain_id: u8, data: Option<impl Into<TransactionData>>, prover: &P, ) -> Result<Self, Error>
Create a new phoenix transaction.
§Errors
The creation of a transaction is not possible and will error if:
- one of the input-notes doesn’t belong to the
sender_sk - the transaction input doesn’t cover the transaction costs
- the
inputsvector is either empty or larger than 4 elements - the
inputsvector contains duplicateNotes - the
Provetrait is implemented incorrectly
Sourcepub fn moonlight(
sender_sk: &AccountSecretKey,
receiver: Option<AccountPublicKey>,
value: u64,
deposit: u64,
gas_limit: u64,
gas_price: u64,
nonce: u64,
chain_id: u8,
data: Option<impl Into<TransactionData>>,
) -> Result<Self, Error>
pub fn moonlight( sender_sk: &AccountSecretKey, receiver: Option<AccountPublicKey>, value: u64, deposit: u64, gas_limit: u64, gas_price: u64, nonce: u64, chain_id: u8, data: Option<impl Into<TransactionData>>, ) -> Result<Self, Error>
Create a new moonlight transaction.
§Errors
The creation of a transaction is not possible and will error if:
- the memo, if given, is too large
Sourcepub fn moonlight_sender(&self) -> Option<&AccountPublicKey>
pub fn moonlight_sender(&self) -> Option<&AccountPublicKey>
Return the sender of the account for Moonlight transactions.
Sourcepub fn moonlight_receiver(&self) -> Option<&AccountPublicKey>
pub fn moonlight_receiver(&self) -> Option<&AccountPublicKey>
Get the receiver of the transaction for Moonlight transactions, if it exists.
§Returns
Some(&AccountPublicKey)if the transaction is a Moonlight transaction and the receiver is different from the sender.Noneif the transaction is a Moonlight transaction and the receiver is the same as the sender.Noneif the transaction is a Phoenix transaction.
Sourcepub fn nullifiers(&self) -> &[BlsScalar]
pub fn nullifiers(&self) -> &[BlsScalar]
Returns the nullifiers of the transaction, if the transaction is a moonlight transaction, the result will be empty.
Sourcepub fn root(&self) -> Option<&BlsScalar>
pub fn root(&self) -> Option<&BlsScalar>
Return the root of the UTXO tree for Phoenix transactions.
Sourcepub fn phoenix_sender(&self) -> Option<&Sender>
pub fn phoenix_sender(&self) -> Option<&Sender>
Returns the sender data for Phoenix transactions.
Sourcepub fn refund_address(&self) -> RefundAddress<'_>
pub fn refund_address(&self) -> RefundAddress<'_>
Returns the refund-address of the transaction.
Sourcepub fn call(&self) -> Option<&ContractCall>
pub fn call(&self) -> Option<&ContractCall>
Return the contract call data, if there is any.
Call data is present only when inter-contract calls happen.
§Returns
Some(&ContractCall)if the transaction invokes another call to a contract.Noneif the transaction is an entrypoint call to a protocol contract without a second call attached to it.
Sourcepub fn deploy(&self) -> Option<&ContractDeploy>
pub fn deploy(&self) -> Option<&ContractDeploy>
Return the contract deploy data, if there is any.
Sourcepub fn blob(&self) -> Option<&Vec<BlobData>>
pub fn blob(&self) -> Option<&Vec<BlobData>>
Returns the Blob used with the transaction, if any.
Sourcepub fn blob_mut(&mut self) -> Option<&mut Vec<BlobData>>
pub fn blob_mut(&mut self) -> Option<&mut Vec<BlobData>>
Returns the Blob used with the transaction, if any.
Sourcepub fn strip_blobs(&mut self) -> Option<Vec<([u8; 32], BlobSidecar)>>
pub fn strip_blobs(&mut self) -> Option<Vec<([u8; 32], BlobSidecar)>>
Extracts and removes the blob sidecar from the transaction, if any, and returns it as a vector of tuples containing the blob hash and the corresponding blob sidecar.
This function mutably accesses the blob storage within the transaction, clears the stored data, and returns the extracted parts while preserving their hashes.
Returns None if there are no blobs present in the transaction.
Sourcepub fn blob_to_memo(&self) -> Option<Self>
pub fn blob_to_memo(&self) -> Option<Self>
Creates a modified clone of this transaction if it contains a Blob, clones all fields except for the Blob, whose versioned hashes are set as Memo.
Returns none if the transaction is not a Blob transaction.
Sourcepub fn strip_off_bytecode(&self) -> Option<Self>
pub fn strip_off_bytecode(&self) -> Option<Self>
Creates a modified clone of this transaction if it contains data for deployment, clones all fields except for the bytecode’ ‘bytes’ part. Returns none if the transaction is not a deployment transaction.
Sourcepub fn to_var_bytes(&self) -> Vec<u8>
pub fn to_var_bytes(&self) -> Vec<u8>
Serialize the transaction into a byte buffer.
Sourcepub fn from_slice(buf: &[u8]) -> Result<Self, BytesError>
pub fn from_slice(buf: &[u8]) -> Result<Self, BytesError>
Sourcepub fn to_hash_input_bytes(&self) -> Vec<u8>
pub fn to_hash_input_bytes(&self) -> Vec<u8>
Return input bytes to hash the transaction.
Note: The result of this function is only meant to be used as an input for hashing and cannot be used to deserialize the transaction again.
Sourcepub fn deploy_charge(
&self,
gas_per_deploy_byte: u64,
min_deploy_points: u64,
) -> u64
pub fn deploy_charge( &self, gas_per_deploy_byte: u64, min_deploy_points: u64, ) -> u64
Returns the charge for a contract deployment. The deployment of a
contract will cost at least min_deploy_points.
If the transaction is not a deploy-transaction, the deploy-charge will
be 0.
Sourcepub fn blob_charge(&self, gas_per_blob: u64) -> Option<u64>
pub fn blob_charge(&self, gas_per_blob: u64) -> Option<u64>
Returns the minimum gas charged for a blob transaction deployment. If the transaction is not a blob transaction, it returns None.
Sourcepub fn deploy_check(
&self,
gas_per_deploy_byte: u64,
min_deploy_gas_price: u64,
min_deploy_points: u64,
) -> Result<(), TxPreconditionError>
pub fn deploy_check( &self, gas_per_deploy_byte: u64, min_deploy_gas_price: u64, min_deploy_points: u64, ) -> Result<(), TxPreconditionError>
Check if the transaction is a deployment transaction and if it meets the minimum requirements for gas price and gas limit.
§Errors
Returns an error if the transaction is a deployment transaction and the gas price is lower than the minimum required gas price or if the gas limit is lower than the required deployment charge.
Sourcepub fn blob_check(
&self,
gas_per_blob: u64,
) -> Result<Option<u64>, TxPreconditionError>
pub fn blob_check( &self, gas_per_blob: u64, ) -> Result<Option<u64>, TxPreconditionError>
Check if the transaction is a blob transaction and if it meets the minimum requirements for gas limit.
§Returns
Ok(Some(u64))the minimum gas amount to charge if the transaction is a blob transaction.Ok(None)if the transaction is not a blob transaction.Err(TxPreconditionError)in case of an error.
§Errors
Returns an error if the transaction is a blob transaction and:
- the gas limit is lower than the minimum charge.
- the number of blobs is zero or greater than 6.
Trait Implementations§
Source§impl Archive for Transaction
impl Archive for Transaction
Source§type Archived = ArchivedTransaction
type Archived = ArchivedTransaction
Source§type Resolver = TransactionResolver
type Resolver = TransactionResolver
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Transaction
impl Debug for Transaction
Source§impl<__D: Fallible + ?Sized> Deserialize<Transaction, __D> for Archived<Transaction>
impl<__D: Fallible + ?Sized> Deserialize<Transaction, __D> for Archived<Transaction>
Source§fn deserialize(&self, deserializer: &mut __D) -> Result<Transaction, __D::Error>
fn deserialize(&self, deserializer: &mut __D) -> Result<Transaction, __D::Error>
Source§impl From<Transaction> for Transaction
impl From<Transaction> for Transaction
Source§fn from(tx: PhoenixTransaction) -> Self
fn from(tx: PhoenixTransaction) -> Self
Source§impl From<Transaction> for Transaction
impl From<Transaction> for Transaction
Source§fn from(tx: MoonlightTransaction) -> Self
fn from(tx: MoonlightTransaction) -> Self
Source§impl PartialEq for Transaction
impl PartialEq for Transaction
impl Eq for Transaction
impl StructuralPartialEq for Transaction
Auto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be unsized. Read moreSource§type MetadataResolver = ()
type MetadataResolver = ()
Source§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata,
)
unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T, S> SerializeUnsized<S> for T
impl<T, S> SerializeUnsized<S> for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.