Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A: LightAccounts<'info>> {
    pub input: TransactionInput<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, A>,
    pub merkle_root: [u8; 32],
    pub tx_integrity_hash: [u8; 32],
    pub mint_pubkey: [u8; 32],
    pub transferred_funds: bool,
    pub computed_tx_integrity_hash: bool,
    pub verified_proof: bool,
    pub inserted_leaves: bool,
    pub inserted_nullifier: bool,
    pub fetched_root: bool,
    pub fetched_mint: bool,
}

Fields§

§input: TransactionInput<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, A>§merkle_root: [u8; 32]§tx_integrity_hash: [u8; 32]§mint_pubkey: [u8; 32]§transferred_funds: bool§computed_tx_integrity_hash: bool§verified_proof: bool§inserted_leaves: bool§inserted_nullifier: bool§fetched_root: bool§fetched_mint: bool

Implementations§

Source§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A: LightAccounts<'info>> Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

Source

pub fn new( input: TransactionInput<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, A>, ) -> Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

Source

pub fn transact(&mut self) -> Result<()>

Transact is a wrapper function which computes the integrity hash, checks the root, verifies the zero knowledge proof, inserts leaves, inserts nullifiers, transfers funds and fees.

Source

pub fn emit_indexer_transaction_event(&mut self) -> Result<()>

Source

pub fn verify(&mut self) -> Result<()>

Verifies a Goth16 zero knowledge proof over the bn254 curve.

Source

pub fn compute_tx_integrity_hash(&mut self) -> Result<()>

Computes the integrity hash of the transaction. This hash is an input to the ZKP, and ensures that the relayer cannot change parameters of the internal or unshield transaction. H(recipient_spl||recipient_sol||signer||relayer_fee||encrypted_utxos).

Source

pub fn fetch_root(&mut self) -> Result<()>

Fetches the root according to an index from the passed-in Merkle tree.

Source

pub fn fetch_mint(&mut self) -> Result<()>

Fetches the token mint from passed in sender_spl account. If the sender_spl account is not a token account, native mint is assumed.

Source

pub fn insert_leaves(&mut self) -> Result<()>

Calls the Merkle tree program via cpi to insert transaction leaves.

Source

pub fn insert_nullifiers(&mut self) -> Result<()>

Calls merkle tree via cpi to insert nullifiers.

Source

pub fn transfer_user_funds(&mut self) -> Result<()>

Transfers user funds either to or from a merkle tree liquidity pool.

Source

pub fn transfer_fee(&self) -> Result<()>

Transfers the relayer fee to or from a merkle tree liquidity pool.

Source

pub fn is_shield_spl(&self) -> bool

Checks whether a transaction is a shield by inspecting the public amount.

Source

pub fn is_shield_sol(&self) -> bool

Checks whether a transaction is a deposit by inspecting the public amount.

Source

pub fn check_sol_pool_account_derivation( &self, pubkey: &Pubkey, data: &[u8], ) -> Result<()>

Source

pub fn check_spl_pool_account_derivation( &self, pubkey: &Pubkey, mint: &Pubkey, ) -> Result<()>

Source

pub fn check_completion(&self) -> Result<()>

Source

pub fn check_amount( &self, relayer_fee: u64, amount: [u8; 32], ) -> Result<(u64, u64)>

Trait Implementations§

Source§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A: Clone + LightAccounts<'info>> Clone for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

Source§

fn clone( &self, ) -> Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A> !RefUnwindSafe for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A> !Send for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A> !Sync for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A> !UnwindSafe for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A> Freeze for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A> Unpin for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

§

impl<'a, 'b, 'c, 'info, const NR_CHECKED_INPUTS: usize, const NR_LEAVES: usize, const NR_NULLIFIERS: usize, const NR_PUBLIC_INPUTS: usize, A> UnsafeUnpin for Transaction<'a, 'b, 'c, 'info, NR_CHECKED_INPUTS, NR_LEAVES, NR_NULLIFIERS, NR_PUBLIC_INPUTS, A>

Blanket Implementations§

Source§

impl<T> AbiExample for T

Source§

default fn example() -> T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more