Struct cardano_serialization_lib::Transaction
source · pub struct Transaction { /* private fields */ }
Implementations§
source§impl Transaction
impl Transaction
sourcepub fn to_bytes(&self) -> Vec<u8>
pub fn to_bytes(&self) -> Vec<u8>
Examples found in repository?
More examples
src/tx_builder.rs (line 1781)
1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783
fn build_and_size(&self) -> Result<(TransactionBody, usize), JsError> {
let fee = self
.fee
.ok_or_else(|| JsError::from_str("Fee not specified"))?;
let built = TransactionBody {
inputs: self.inputs.inputs(),
outputs: self.outputs.clone(),
fee,
ttl: self.ttl,
certs: self.certs.clone(),
withdrawals: self.withdrawals.clone(),
update: None,
auxiliary_data_hash: match &self.auxiliary_data {
None => None,
Some(x) => Some(utils::hash_auxiliary_data(x)),
},
validity_start_interval: self.validity_start_interval,
mint: match &self.mint {
None => None,
Some(mint_builder) => Some(mint_builder.build()),
},
script_data_hash: self.script_data_hash.clone(),
collateral: self.collateral.inputs_option(),
required_signers: self.required_signers.to_option(),
network_id: None,
collateral_return: self.collateral_return.clone(),
total_collateral: self.total_collateral.clone(),
reference_inputs: self.get_reference_inputs().to_option(),
};
// we must build a tx with fake data (of correct size) to check the final Transaction size
let full_tx = fake_full_tx(self, built)?;
let full_tx_size = full_tx.to_bytes().len();
return Ok((full_tx.body, full_tx_size));
}
source§impl Transaction
impl Transaction
pub fn from_bytes(bytes: Vec<u8>) -> Result<Transaction, DeserializeError>
source§impl Transaction
impl Transaction
pub fn from_hex(hex_str: &str) -> Result<Transaction, DeserializeError>
source§impl Transaction
impl Transaction
source§impl Transaction
impl Transaction
pub fn body(&self) -> TransactionBody
pub fn witness_set(&self) -> TransactionWitnessSet
pub fn is_valid(&self) -> bool
pub fn auxiliary_data(&self) -> Option<AuxiliaryData>
pub fn set_is_valid(&mut self, valid: bool)
sourcepub fn new(
body: &TransactionBody,
witness_set: &TransactionWitnessSet,
auxiliary_data: Option<AuxiliaryData>
) -> Self
pub fn new(
body: &TransactionBody,
witness_set: &TransactionWitnessSet,
auxiliary_data: Option<AuxiliaryData>
) -> Self
Examples found in repository?
src/tx_builder/batch_tools/proposals.rs (lines 192-196)
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
pub(crate) fn create_tx(&self, asset_groups: &AssetCategorizer, utxos: &TransactionUnspentOutputs)
-> Result<Transaction, JsError> {
let mut outputs = Vec::new();
for proposal in &self.tx_output_proposals {
outputs.push(proposal.create_output(asset_groups, &self.used_utoxs)?);
}
let mut inputs = Vec::new();
for utxo in &self.used_utoxs {
inputs.push(utxos.0[utxo.0].input.clone());
}
let body = TransactionBody::new(
&TransactionInputs(inputs),
&TransactionOutputs(outputs),
&self.fee,
None,
);
let tx = Transaction::new(
&body,
&self.witnesses_calculator.create_mock_witnesses_set(),
None,
);
Ok(tx)
}
Trait Implementations§
source§impl Clone for Transaction
impl Clone for Transaction
source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Deserialize for Transaction
impl Deserialize for Transaction
fn deserialize<R: BufRead + Seek>(
raw: &mut Deserializer<R>
) -> Result<Self, DeserializeError>
source§impl DeserializeEmbeddedGroup for Transaction
impl DeserializeEmbeddedGroup for Transaction
fn deserialize_as_embedded_group<R: BufRead + Seek>(
raw: &mut Deserializer<R>,
_: Len
) -> Result<Self, DeserializeError>
source§impl JsonSchema for Transaction
impl JsonSchema for Transaction
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read more