pub struct Transaction { /* private fields */ }Expand description
Phoenix transaction.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new<R: RngCore + CryptoRng, P: Prove>(
rng: &mut R,
sender_sk: &SecretKey,
refund_pk: &PublicKey,
receiver_pk: &PublicKey,
inputs: Vec<(Note, NoteOpening)>,
root: BlsScalar,
transfer_value: u64,
obfuscate_transfer_note: bool,
deposit: u64,
gas_limit: u64,
gas_price: u64,
chain_id: u8,
data: Option<impl Into<TransactionData>>,
prover: &P,
) -> Result<Self, Error>
pub fn new<R: RngCore + CryptoRng, P: Prove>( rng: &mut R, sender_sk: &SecretKey, refund_pk: &PublicKey, receiver_pk: &PublicKey, inputs: Vec<(Note, NoteOpening)>, root: BlsScalar, transfer_value: u64, obfuscate_transfer_note: 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 given the sender secret-key, receiver public-key, the input note positions in the transaction tree and the new output-notes.
§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
proveris implemented incorrectly - the memo, if given, is too large
Sourcepub fn from_payload_and_proof(payload: Payload, proof: Vec<u8>) -> Self
pub fn from_payload_and_proof(payload: Payload, proof: Vec<u8>) -> Self
Sourcepub fn set_proof(&mut self, proof: Vec<u8>)
pub fn set_proof(&mut self, proof: Vec<u8>)
Replaces the inner proof bytes for a given proof.
This can be used to delegate the proof generation after a
Transaction is created.
In order to do that, the transaction would be created using the
serialized circuit-bytes for the proof-field. Those bytes can be
sent to a 3rd-party prover-service that generates the proof-bytes
and sends them back. The proof-bytes will then replace the
circuit-bytes in the transaction using this function.
Sourcepub fn payload_hash(&self) -> BlsScalar
pub fn payload_hash(&self) -> BlsScalar
The payload-hash of the transaction used as input in the phoenix-circuit.
Sourcepub fn nullifiers(&self) -> &[BlsScalar]
pub fn nullifiers(&self) -> &[BlsScalar]
Returns the nullifiers of the transaction.
Sourcepub fn stealth_address(&self) -> &StealthAddress
pub fn stealth_address(&self) -> &StealthAddress
Return the stealth address for returning funds for Phoenix transactions as specified in the fee.
Sourcepub fn sender(&self) -> &Sender
pub fn sender(&self) -> &Sender
Returns the sender data for Phoenix transactions as specified in the fee.
Sourcepub fn call(&self) -> Option<&ContractCall>
pub fn call(&self) -> Option<&ContractCall>
Return the contract call data, if there is any.
Sourcepub fn deploy(&self) -> Option<&ContractDeploy>
pub fn deploy(&self) -> Option<&ContractDeploy>
Return the contract deploy data, if there is any.
Sourcepub fn blob_mut(&mut self) -> Option<&mut Vec<BlobData>>
pub fn blob_mut(&mut self) -> Option<&mut Vec<BlobData>>
Return the mutable blob data, if there is any.
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 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 to_var_bytes(&self) -> Vec<u8>
pub fn to_var_bytes(&self) -> Vec<u8>
Serialize the Transaction into a variable length 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 public_inputs(&self) -> Vec<BlsScalar>
pub fn public_inputs(&self) -> Vec<BlsScalar>
Return the public input to be used in the phoenix-transaction circuit verification
These are:
payload_hashroot[nullifier; I][output_value_commitment; 2]max_feedeposit(npk_out_0, npk_out_1)(enc_A_npk_out_0, enc_B_npk_out_0)(enc_A_npk_out_1, enc_B_npk_out_1)
§Panics
Panics if one of the output-notes doesn’t have the sender set to
Sender::Encryption.
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 PartialEq for Transaction
impl PartialEq for Transaction
impl Eq 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.