pub struct Signed<T>where
T: Encodable,{
pub payload: T,
pub signature: SignatureType,
pub hash: OnceLock<FixedBytes<32>>,
}Expand description
A transaction with a signature and hash seal.
Fields§
§payload: TThe payload is the raw transaction that submitted by the user.
signature: SignatureTypeThe signature(s) - either single or multi-sig
hash: OnceLock<FixedBytes<32>>The hash of the transaction, which is used to identify the transaction. And it’s calculated by the payload and the signature, and no need to be serialized and stored in the database.
Implementations§
Source§impl<T> Signed<T>where
T: Encodable,
impl<T> Signed<T>where
T: Encodable,
Sourcepub fn is_multi_sig(&self) -> bool
pub fn is_multi_sig(&self) -> bool
Check if this is a multi-sig transaction
Sourcepub fn multi_sig_info(&self) -> Option<(Address, &[MultiSigSignatureEntry])>
pub fn multi_sig_info(&self) -> Option<(Address, &[MultiSigSignatureEntry])>
Get the multi-sig account and signatures if this is a multi-sig transaction
Sourcepub fn signature_count(&self) -> usize
pub fn signature_count(&self) -> usize
Get the number of signatures in this transaction
Source§impl<T> Signed<T>where
T: Encodable + TxHashable,
impl<T> Signed<T>where
T: Encodable + TxHashable,
Sourcepub fn new(payload: T, signature: Signature) -> Signed<T>
pub fn new(payload: T, signature: Signature) -> Signed<T>
Creates a new signed transaction with a single signature.
The transaction hash is computed immediately and cached in OnceLock.
Sourcepub fn new_multi_sig(
payload: T,
multisig_account: Address,
signatures: Vec<MultiSigSignatureEntry>,
) -> Signed<T>
pub fn new_multi_sig( payload: T, multisig_account: Address, signatures: Vec<MultiSigSignatureEntry>, ) -> Signed<T>
Creates a new multi-sig transaction with multiple signatures.
The transaction hash includes all signatures to ensure uniqueness.
§Arguments
payload- The transaction payloadmultisig_account- The multi-sig account address (sender)signatures- The list of signatures from authorized signers
Sourcepub fn new_unchecked(
payload: T,
signature: Signature,
hash: FixedBytes<32>,
) -> Signed<T>
pub fn new_unchecked( payload: T, signature: Signature, hash: FixedBytes<32>, ) -> Signed<T>
Creates a new signed transaction with the given payload and signature, and the hash of the transaction is already calculated. The function will not calculate the hash again, so the caller should ensure the hash is correct.
It’s mainly used for testing.
Sourcepub fn new_unhashed(payload: T, signature: Signature) -> Signed<T>
pub fn new_unhashed(payload: T, signature: Signature) -> Signed<T>
Creates a new signed transaction with the given payload and signature, but without hashing the transaction. And when getting the hash at the first time, it will be calculated.
Sourcepub fn signature(&self) -> &SignatureType
pub fn signature(&self) -> &SignatureType
Returns the signature(s) of the signed transaction.
Sourcepub fn signature_type(&self) -> &SignatureType
pub fn signature_type(&self) -> &SignatureType
Returns the signature(s) of the signed transaction.
Alias for signature() for backwards compatibility.
Sourcepub fn hash(&self) -> &FixedBytes<32>
pub fn hash(&self) -> &FixedBytes<32>
Returns the hash of the signed transaction, the hash is calculated when first time called (for deserialized transactions), and cached in OnceLock.
Sourcepub fn slow_hash(&self) -> FixedBytes<32>
pub fn slow_hash(&self) -> FixedBytes<32>
Returns the hash of the raw transaction with signature.
This is slower than hash() as it recalculates every time.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Signed<T>where
T: Encodable + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Signed<T>where
T: Encodable + Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Signed<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Signed<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<Signed<PaymentPayload>> for RawTransactionEnvelope
impl From<Signed<PaymentPayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<PaymentPayload>) -> RawTransactionEnvelope
fn from(signed: Signed<PaymentPayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenAuthorityPayload>> for RawTransactionEnvelope
impl From<Signed<TokenAuthorityPayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenAuthorityPayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenAuthorityPayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenBlacklistPayload>> for RawTransactionEnvelope
impl From<Signed<TokenBlacklistPayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenBlacklistPayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenBlacklistPayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenBurnPayload>> for RawTransactionEnvelope
impl From<Signed<TokenBurnPayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenBurnPayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenBurnPayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenClawbackPayload>> for RawTransactionEnvelope
impl From<Signed<TokenClawbackPayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenClawbackPayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenClawbackPayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenMetadataUpdatePayload>> for RawTransactionEnvelope
impl From<Signed<TokenMetadataUpdatePayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenMetadataUpdatePayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenMetadataUpdatePayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenMintPayload>> for RawTransactionEnvelope
impl From<Signed<TokenMintPayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenMintPayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenMintPayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenPausePayload>> for RawTransactionEnvelope
impl From<Signed<TokenPausePayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenPausePayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenPausePayload>) -> RawTransactionEnvelope
Source§impl From<Signed<TokenWhitelistPayload>> for RawTransactionEnvelope
impl From<Signed<TokenWhitelistPayload>> for RawTransactionEnvelope
Source§fn from(signed: Signed<TokenWhitelistPayload>) -> RawTransactionEnvelope
fn from(signed: Signed<TokenWhitelistPayload>) -> RawTransactionEnvelope
Source§impl<T> Serialize for Signed<T>
impl<T> Serialize for Signed<T>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl<T> SignerRecoverable for Signed<T>
impl<T> SignerRecoverable for Signed<T>
impl<T> Eq for Signed<T>
impl<T> StructuralPartialEq for Signed<T>where
T: Encodable,
Auto Trait Implementations§
impl<T> !Freeze for Signed<T>
impl<T> RefUnwindSafe for Signed<T>where
T: RefUnwindSafe,
impl<T> Send for Signed<T>where
T: Send,
impl<T> Sync for Signed<T>where
T: Sync,
impl<T> Unpin for Signed<T>where
T: Unpin,
impl<T> UnwindSafe for Signed<T>where
T: UnwindSafe,
Blanket Implementations§
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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