pub struct Transaction { /* private fields */ }Expand description
Represents a Kaspa transaction. This is an artificial construct that includes additional transaction-related data such as additional data from UTXOs used by transaction inputs. @category Consensus
Implementations§
Source§impl Transaction
impl Transaction
pub fn new( id: Option<TransactionId>, version: u16, inputs: Vec<TransactionInput>, outputs: Vec<TransactionOutput>, lock_time: u64, subnetwork_id: SubnetworkId, gas: u64, payload: Vec<u8>, mass: u64, ) -> Result<Self>
pub fn new_with_inner(inner: TransactionInner) -> Self
pub fn inner(&self) -> MutexGuard<'_, TransactionInner>
pub fn id(&self) -> TransactionId
Source§impl Transaction
impl Transaction
Sourcepub fn is_coinbase(&self) -> bool
pub fn is_coinbase(&self) -> bool
Determines whether or not a transaction is a coinbase transaction. A coinbase transaction is a special transaction created by miners that distributes fees and block subsidy to the previous blocks’ miners, and specifies the script_pub_key that will be used to pay the current miner in future blocks.
Sourcepub fn finalize(&self) -> Result<TransactionId>
pub fn finalize(&self) -> Result<TransactionId>
Recompute and finalize the tx id based on updated tx fields
pub fn constructor(js_value: &TransactionT) -> Result<Transaction, JsError>
pub fn get_inputs_as_js_array(&self) -> TransactionInputArrayAsResultT
Sourcepub fn addresses(&self, network_type: &NetworkTypeT) -> Result<AddressArrayT>
pub fn addresses(&self, network_type: &NetworkTypeT) -> Result<AddressArrayT>
Returns a list of unique addresses used by transaction inputs. This method can be used to determine addresses used by transaction inputs in order to select private keys needed for transaction signing.
pub fn set_inputs_from_js_array( &mut self, js_value: &TransactionInputArrayAsArgT, )
pub fn get_outputs_as_js_array(&self) -> TransactionOutputArrayAsResultT
pub fn set_outputs_from_js_array( &mut self, js_value: &TransactionOutputArrayAsArgT, )
pub fn get_version(&self) -> u16
pub fn set_version(&self, v: u16)
pub fn get_lock_time(&self) -> u64
pub fn set_lock_time(&self, v: u64)
pub fn get_gas(&self) -> u64
pub fn set_gas(&self, v: u64)
pub fn get_subnetwork_id_as_hex(&self) -> String
pub fn set_subnetwork_id_from_js_value(&mut self, js_value: JsValue)
pub fn get_payload_as_hex_string(&self) -> String
pub fn set_payload_from_js_value(&mut self, js_value: JsValue)
pub fn get_mass(&self) -> u64
pub fn set_mass(&self, v: u64)
Source§impl Transaction
impl Transaction
pub fn from_cctx_transaction( tx: &Transaction, utxos: &AHashMap<UtxoEntryId, UtxoEntryReference>, ) -> Self
pub fn tx_and_utxos(&self) -> Result<(Transaction, Vec<UtxoEntry>)>
pub fn utxo_entry_references(&self) -> Result<Vec<UtxoEntryReference>>
pub fn outputs(&self) -> Vec<TransactionOutput>
pub fn inputs(&self) -> Vec<TransactionInput>
pub fn inputs_outputs(&self) -> (Vec<TransactionInput>, Vec<TransactionOutput>)
pub fn set_signature_script( &self, input_index: usize, signature_script: Vec<u8>, ) -> Result<()>
pub fn payload(&self) -> Vec<u8> ⓘ
pub fn payload_len(&self) -> usize
Source§impl Transaction
impl Transaction
Sourcepub fn serialize_to_object(&self) -> Result<SerializableTransactionT>
pub fn serialize_to_object(&self) -> Result<SerializableTransactionT>
Serializes the transaction to a pure JavaScript Object. The schema of the JavaScript object is defined by {@link ISerializableTransaction}. @see {@link ISerializableTransaction}
Sourcepub fn serialize_to_json(&self) -> Result<String>
pub fn serialize_to_json(&self) -> Result<String>
Serializes the transaction to a JSON string. The schema of the JSON is defined by {@link ISerializableTransaction}.
Sourcepub fn serialize_to_json_safe(&self) -> Result<String>
pub fn serialize_to_json_safe(&self) -> Result<String>
Serializes the transaction to a “Safe” JSON schema where it converts all bigint values to string to avoid potential client-side precision loss.
Sourcepub fn deserialize_from_object(js_value: &JsValue) -> Result<Transaction>
pub fn deserialize_from_object(js_value: &JsValue) -> Result<Transaction>
Deserialize the {@link Transaction} Object from a pure JavaScript Object.
Sourcepub fn deserialize_from_json(json: &str) -> Result<Transaction>
pub fn deserialize_from_json(json: &str) -> Result<Transaction>
Deserialize the {@link Transaction} Object from a JSON string.
Sourcepub fn deserialize_from_safe_json(json: &str) -> Result<Transaction>
pub fn deserialize_from_safe_json(json: &str) -> Result<Transaction>
Deserialize the {@link Transaction} Object from a “Safe” JSON schema where all bigint values are represented as string.
Trait Implementations§
Source§impl CastFromJs for Transaction
impl CastFromJs for Transaction
Source§fn try_ref_from_js_value<'a, R>(
js: &'a R,
) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
fn try_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
JsValueSource§fn try_long_ref_from_js_value<'a, R>(
js: &'a R,
) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
fn try_long_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
JsValuefn try_ref_from_js_value_as_cast<'a, R>( js_value: &'a R, ) -> Result<Cast<'a, Self>, Error>
fn try_long_ref_from_js_value_as_cast<'a, R>( js: &'a R, ) -> Result<Cast<'a, Self>, Error>
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0§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<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<&Transaction> for Transaction
impl From<&Transaction> for Transaction
Source§fn from(tx: &Transaction) -> Self
fn from(tx: &Transaction) -> Self
Source§impl From<Transaction> for JsValue
impl From<Transaction> for JsValue
Source§fn from(value: Transaction) -> Self
fn from(value: Transaction) -> Self
Source§impl From<Transaction> for Transaction
impl From<Transaction> for Transaction
Source§fn from(tx: Transaction) -> Self
fn from(tx: Transaction) -> Self
Source§impl FromWasmAbi for Transaction
impl FromWasmAbi for Transaction
Source§impl IntoWasmAbi for Transaction
impl IntoWasmAbi for Transaction
Source§impl LongRefFromWasmAbi for Transaction
impl LongRefFromWasmAbi for Transaction
Source§impl OptionFromWasmAbi for Transaction
impl OptionFromWasmAbi for Transaction
Source§impl OptionIntoWasmAbi for Transaction
impl OptionIntoWasmAbi for Transaction
Source§impl RefFromWasmAbi for Transaction
impl RefFromWasmAbi for Transaction
Source§type Anchor = RcRef<Transaction>
type Anchor = RcRef<Transaction>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for Transaction
impl RefMutFromWasmAbi for Transaction
Source§impl Serialize for Transaction
impl Serialize for Transaction
Source§impl TryCastFromJs for Transaction
impl TryCastFromJs for Transaction
type Error = Error
Source§fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'_, Self>, Self::Error>
fn try_cast_from<'a, R>(value: &'a R) -> Result<Cast<'_, Self>, Self::Error>
Cast.Source§fn try_owned_from(value: impl AsRef<JsValue>) -> Result<Self, Self::Error>
fn try_owned_from(value: impl AsRef<JsValue>) -> Result<Self, Self::Error>
Cast container.
This function will return a temporary user-created
object created during [try_cast_from] or a clone of the casted reference.fn try_captured_cast_from( js_value: impl AsRef<JsValue>, ) -> Result<Cast<'static, Self>, Self::Error>
Source§fn resolve<'a, R>(
js: &'a R,
create: impl FnOnce() -> Result<Self, Self::Error>,
) -> Result<Cast<'a, Self>, Self::Error>
fn resolve<'a, R>( js: &'a R, create: impl FnOnce() -> Result<Self, Self::Error>, ) -> Result<Cast<'a, Self>, Self::Error>
Source§fn resolve_cast<'a, R>(
js: &'a R,
create: impl FnOnce() -> Result<Cast<'a, Self>, Self::Error>,
) -> Result<Cast<'a, Self>, Self::Error>
fn resolve_cast<'a, R>( js: &'a R, create: impl FnOnce() -> Result<Cast<'a, Self>, Self::Error>, ) -> Result<Cast<'a, Self>, Self::Error>
resolve]
function, this function expects create closure to return a Cast.
This is useful when routing the creation of the object to another
function that is capable of creating a compatible Cast wrapper.Source§impl TryFrom<SerializableTransaction> for Transaction
impl TryFrom<SerializableTransaction> for Transaction
Source§impl TryFrom<SerializableTransaction> for Transaction
impl TryFrom<SerializableTransaction> for Transaction
Source§impl TryFromJsValue for Transaction
impl TryFromJsValue for Transaction
Source§impl VectorFromWasmAbi for Transaction
impl VectorFromWasmAbi for Transaction
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Transaction]>
Source§impl VectorIntoWasmAbi for Transaction
impl VectorIntoWasmAbi for Transaction
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[Transaction]>) -> Self::Abi
Source§impl WasmDescribeVector for Transaction
impl WasmDescribeVector for Transaction
impl SupportsConstructor for Transaction
impl SupportsInstanceProperty for Transaction
impl SupportsStaticProperty 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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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 moreSource§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.