Struct Transaction

Source
pub struct Transaction {
Show 14 fields pub timestamp: Timestamp, pub from: Vec<Slip>, pub to: Vec<Slip>, pub data: Vec<u8>, pub transaction_type: TransactionType, pub txs_replacements: u32, pub signature: SaitoSignature, pub path: Vec<Hop>, pub hash_for_signature: Option<SaitoHash>, pub total_in: Currency, pub total_out: Currency, pub total_fees: Currency, pub total_work_for_me: Currency, pub cumulative_fees: Currency,
}

Fields§

§timestamp: Timestamp§from: Vec<Slip>§to: Vec<Slip>§data: Vec<u8>§transaction_type: TransactionType§txs_replacements: u32§signature: SaitoSignature§path: Vec<Hop>§hash_for_signature: Option<SaitoHash>§total_in: Currency

total nolan in input slips

§total_out: Currency

total nolan in output slips

§total_fees: Currency

total fees

§total_work_for_me: Currency

total work to creator

§cumulative_fees: Currency

cumulative fees for this tx-in-block

Implementations§

Source§

impl Transaction

Source

pub fn add_hop( &mut self, my_private_key: &SaitoPrivateKey, my_public_key: &SaitoPublicKey, to_public_key: &SaitoPublicKey, )

Source

pub fn add_from_slip(&mut self, input_slip: Slip)

add input slip

§Arguments
  • input_slip:

returns: ()

§Examples
Source

pub fn add_to_slip(&mut self, output_slip: Slip)

add output slip

§Arguments
  • output_slip:

returns: ()

§Examples
Source

pub fn create( wallet: &mut Wallet, to_public_key: SaitoPublicKey, with_payment: Currency, with_fee: Currency, _force_merge: bool, network: Option<&Network>, latest_block_id: u64, genesis_period: u64, ) -> Result<Transaction, Error>

this function exists largely for testing. It attempts to attach the requested fee to the transaction if possible. If not possible it reverts back to a transaction with 1 zero-fee input and 1 zero-fee output.

§Arguments
  • wallet_lock:
  • to_publickey:
  • with_payment:
  • with_fee:

returns: Transaction

§Examples
Source

pub fn create_with_multiple_payments( wallet: &mut Wallet, keys: Vec<SaitoPublicKey>, payments: Vec<Currency>, with_fee: Currency, network: Option<&Network>, latest_block_id: u64, genesis_period: u64, ) -> Result<Transaction, Error>

Source

pub fn create_issuance_transaction( to_public_key: SaitoPublicKey, with_amount: Currency, ) -> Transaction

§Arguments
  • to_publickey:
  • with_amount:

returns: Transaction

§Examples
Source

pub fn create_rebroadcast_transaction( transaction_to_rebroadcast: &Transaction, to_slip: Slip, from_slip: Slip, ) -> Transaction

create rebroadcast transaction

§Arguments
  • transaction_to_rebroadcast:
  • output_slip_to_rebroadcast:
  • with_fee:
  • with_staking_subsidy:

returns: Transaction

§Examples
Source

pub fn create_rebroadcast_bound_transaction( transaction_to_rebroadcast: &Transaction, slip1: Slip, slip2: Slip, slip3: Slip, ) -> Transaction

Source

pub async fn delete(&self, utxoset: &mut UtxoSet) -> bool

Source

pub fn deserialize_from_net(bytes: &[u8]) -> Result<Transaction, Error>

Deserialize from bytes to a Transaction. [len of inputs - 4 bytes - u32] [len of outputs - 4 bytes - u32] [len of message - 4 bytes - u32] [len of path - 4 bytes - u32] [signature - 64 bytes - Secp25k1 sig] [timestamp - 8 bytes - u64] [transaction type - 1 byte] [input][input][input]… [output][output][output]… [message] [hop][hop][hop]…

Source

pub fn is_fee_transaction(&self) -> bool

Source

pub fn is_staking_transaction(&self) -> bool

Source

pub fn is_atr_transaction(&self) -> bool

Source

pub fn is_normal_transaction(&self) -> bool

Source

pub fn is_golden_ticket(&self) -> bool

Source

pub fn is_issuance_transaction(&self) -> bool

Source

pub fn generate( &mut self, public_key: &SaitoPublicKey, tx_index: u64, block_id: u64, ) -> bool

Source

pub fn generate_cumulative_fees( &mut self, cumulative_fees: Currency, ) -> Currency

Source

pub fn generate_total_fees(&mut self, tx_index: u64, block_id: u64)

Source

pub fn generate_total_work(&mut self, public_key: &SaitoPublicKey)

calculate cumulative routing work in block

Source

pub fn generate_hash_for_signature(&mut self)

Source

pub fn get_winning_routing_node(&self, random_hash: SaitoHash) -> SaitoPublicKey

Source

pub fn on_chain_reorganization( &self, utxoset: &mut UtxoSet, longest_chain: bool, )

Runs when the chain is re-organized

Source

pub fn serialize_for_net(&self) -> Vec<u8>

[len of inputs - 4 bytes - u32] [len of outputs - 4 bytes - u32] [len of message - 4 bytes - u32] [len of path - 4 bytes - u32] [signature - 64 bytes - Secp25k1 sig] [timestamp - 8 bytes - u64] [transaction type - 1 byte] [input][input][input]… [output][output][output]… [message] [hop][hop][hop]…

Source

pub fn get_serialized_size(&self) -> usize

Returns the size of the serialized transaction buffer without serializing

Source

pub fn serialize_for_signature(&self) -> Vec<u8>

Source

pub fn sign(&mut self, private_key: &SaitoPrivateKey)

Source

pub fn validate( &self, utxoset: &UtxoSet, blockchain: &Blockchain, validate_against_utxo: bool, ) -> bool

Source

pub fn validate_against_utxoset(&self, utxoset: &UtxoSet) -> bool

Source

pub fn validate_routing_path(&self) -> bool

Source

pub fn is_in_path(&self, public_key: &SaitoPublicKey) -> bool

Source

pub fn is_from(&self, public_key: &SaitoPublicKey) -> bool

Source

pub fn is_to(&self, public_key: &SaitoPublicKey) -> bool

Source

pub fn is_nft(&self, slips: &[Slip], i: usize) -> bool

Trait Implementations§

Source§

impl Clone for Transaction

Source§

fn clone(&self) -> Transaction

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transaction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Transaction

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Transaction

Source§

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 Display for Transaction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Transaction

Source§

fn eq(&self, other: &Transaction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Transaction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Transaction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,