pub struct Transaction { /* private fields */ }Expand description
Moonlight transaction.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(
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 new( 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 transaction.
§Errors
The creation of a transaction is not possible and will error if:
- the memo, if given, is too large
Sourcepub fn new_with_refund(
sender_sk: &AccountSecretKey,
refund_pk: &AccountPublicKey,
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 new_with_refund( sender_sk: &AccountSecretKey, refund_pk: &AccountPublicKey, 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 transaction with a specified refund-address for the gas refund.
§Errors
The creation of a transaction is not possible and will error if:
- the memo, if given, is too large
Sourcepub fn sign_payload(
sender_sk: &AccountSecretKey,
payload: Payload,
) -> Result<Self, Error>
pub fn sign_payload( sender_sk: &AccountSecretKey, payload: Payload, ) -> Result<Self, Error>
Create a transaction by signing a previously generated payload with a given secret-key.
Note that this transaction will be invalid if the secret-key used for
signing doesn’t form a valid key-pair with the public-key of the
sender.
§Errors
The creation of a transaction is not possible and will error if:
- the payload memo, if given, is too large
Sourcepub fn signature(&self) -> &AccountSignature
pub fn signature(&self) -> &AccountSignature
The proof of the transaction.
Sourcepub fn sender(&self) -> &AccountPublicKey
pub fn sender(&self) -> &AccountPublicKey
Return the sender of the transaction.
Sourcepub fn refund_address(&self) -> &AccountPublicKey
pub fn refund_address(&self) -> &AccountPublicKey
Return the address to send the transaction refund to.
Sourcepub fn receiver(&self) -> Option<&AccountPublicKey>
pub fn receiver(&self) -> Option<&AccountPublicKey>
Return the receiver of the transaction if it’s different from the sender. Otherwise, return None.
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 data(&self) -> Option<&TransactionData>
pub fn data(&self) -> Option<&TransactionData>
Returns the transaction data, if it exists.
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 a 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 payload.
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 signature_message(&self) -> Vec<u8>
pub fn signature_message(&self) -> Vec<u8>
Return the message that is meant to be signed over to make the transaction a valid one.
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>where
Payload: Archive,
Archived<Payload>: Deserialize<Payload, __D>,
AccountSignature: Archive,
Archived<AccountSignature>: Deserialize<AccountSignature, __D>,
impl<__D: Fallible + ?Sized> Deserialize<Transaction, __D> for Archived<Transaction>where
Payload: Archive,
Archived<Payload>: Deserialize<Payload, __D>,
AccountSignature: Archive,
Archived<AccountSignature>: Deserialize<AccountSignature, __D>,
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: 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.