Struct grin_core::core::transaction::Transaction
source · pub struct Transaction {
pub offset: BlindingFactor,
pub body: TransactionBody,
}
Expand description
A transaction
Fields§
§offset: BlindingFactor
The kernel “offset” k2 excess is k1G after splitting the key k = k1 + k2
body: TransactionBody
The transaction body - inputs/outputs/kernels
Implementations§
source§impl Transaction
impl Transaction
sourcepub fn empty() -> Transaction
pub fn empty() -> Transaction
Creates a new empty transaction (no inputs or outputs, zero fee).
sourcepub fn new(
inputs: Inputs,
outputs: &[Output],
kernels: &[TxKernel]
) -> Transaction
pub fn new( inputs: Inputs, outputs: &[Output], kernels: &[TxKernel] ) -> Transaction
Creates a new transaction initialized with the provided inputs, outputs, kernels
sourcepub fn with_offset(self, offset: BlindingFactor) -> Transaction
pub fn with_offset(self, offset: BlindingFactor) -> Transaction
Creates a new transaction using this transaction as a template and with the specified offset.
sourcepub fn with_input(self, input: Input) -> Transaction
pub fn with_input(self, input: Input) -> Transaction
Builds a new transaction with the provided inputs added. Existing inputs, if any, are kept intact. Sort order is maintained.
sourcepub fn with_output(self, output: Output) -> Transaction
pub fn with_output(self, output: Output) -> Transaction
Builds a new transaction with the provided output added. Existing outputs, if any, are kept intact. Sort order is maintained.
sourcepub fn with_kernel(self, kernel: TxKernel) -> Transaction
pub fn with_kernel(self, kernel: TxKernel) -> Transaction
Builds a new transaction with the provided kernel added. Existing kernels, if any, are kept intact. Sort order is maintained.
sourcepub fn replace_kernel(self, kernel: TxKernel) -> Transaction
pub fn replace_kernel(self, kernel: TxKernel) -> Transaction
Builds a new transaction replacing any existing kernels with the provided kernel.
sourcepub fn shifted_fee(&self) -> u64
pub fn shifted_fee(&self) -> u64
Shifted fee for a transaction is the sum of fees of all kernels shifted right by the maximum fee shift
sourcepub fn aggregate_fee_fields(&self) -> Result<FeeFields, Error>
pub fn aggregate_fee_fields(&self) -> Result<FeeFields, Error>
aggregate fee_fields from all appropriate kernels in transaction into one
sourcepub fn lock_height(&self) -> u64
pub fn lock_height(&self) -> u64
Lock height of a transaction is the max lock height of the kernels.
sourcepub fn validate_read(&self) -> Result<(), Error>
pub fn validate_read(&self) -> Result<(), Error>
“Lightweight” validation that we can perform quickly during read/deserialization. Subset of full validation that skips expensive verification steps, specifically -
- rangeproof verification (on the body)
- kernel signature verification (on the body)
- kernel sum verification
sourcepub fn validate(&self, weighting: Weighting) -> Result<(), Error>
pub fn validate(&self, weighting: Weighting) -> Result<(), Error>
Validates all relevant parts of a fully built transaction. Checks the excess value against the signature as well as range proofs for each output.
sourcepub fn fee_rate(&self) -> u64
pub fn fee_rate(&self) -> u64
Can be used to compare txs by their fee/weight ratio, aka feerate. Don’t use these values for anything else though due to precision multiplier.
sourcepub fn accept_fee(&self) -> u64
pub fn accept_fee(&self) -> u64
Transaction minimum acceptable fee
Trait Implementations§
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 Committed for Transaction
impl Committed for Transaction
source§fn inputs_committed(&self) -> Vec<Commitment>
fn inputs_committed(&self) -> Vec<Commitment>
source§fn outputs_committed(&self) -> Vec<Commitment>
fn outputs_committed(&self) -> Vec<Commitment>
source§fn kernels_committed(&self) -> Vec<Commitment>
fn kernels_committed(&self) -> Vec<Commitment>
source§fn sum_kernel_excesses(
&self,
offset: &BlindingFactor
) -> Result<(Commitment, Commitment), Error>
fn sum_kernel_excesses( &self, offset: &BlindingFactor ) -> Result<(Commitment, Commitment), Error>
source§fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>
fn sum_commitments(&self, overage: i64) -> Result<Commitment, Error>
source§fn verify_kernel_sums(
&self,
overage: i64,
kernel_offset: BlindingFactor
) -> Result<(Commitment, Commitment), Error>
fn verify_kernel_sums( &self, overage: i64, kernel_offset: BlindingFactor ) -> Result<(Commitment, Commitment), Error>
source§impl Debug for Transaction
impl Debug for Transaction
source§impl Default for Transaction
impl Default for Transaction
source§fn default() -> Transaction
fn default() -> 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 TransactionBody
impl From<Transaction> for TransactionBody
source§fn from(tx: Transaction) -> Self
fn from(tx: Transaction) -> Self
source§impl PartialEq for Transaction
impl PartialEq for Transaction
PartialEq
source§fn eq(&self, tx: &Transaction) -> bool
fn eq(&self, tx: &Transaction) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Readable for Transaction
impl Readable for Transaction
Implementation of Readable for a transaction, defines how to read a full transaction from a binary stream.
source§impl Serialize for Transaction
impl Serialize for Transaction
source§impl Writeable for Transaction
impl Writeable for Transaction
Implementation of Writeable for a fully blinded transaction, defines how to write the transaction as binary.
impl DefaultHashable 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> 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<D> Hashed for Dwhere
D: DefaultHashable,
impl<D> Hashed for Dwhere
D: DefaultHashable,
source§impl<T> PMMRIndexHashable for Twhere
T: DefaultHashable,
impl<T> PMMRIndexHashable for Twhere
T: DefaultHashable,
source§fn hash_with_index(&self, index: u64) -> Hash
fn hash_with_index(&self, index: u64) -> Hash
source§impl<H> ShortIdentifiable for Hwhere
H: Hashed,
impl<H> ShortIdentifiable for Hwhere
H: Hashed,
source§fn short_id(&self, hash: &Hash, nonce: u64) -> ShortId
fn short_id(&self, hash: &Hash, nonce: u64) -> ShortId
Generate a short_id via the following -
- extract k0/k1 from block_hash hashed with the nonce (first two u64
values) * initialize a siphasher24 with k0/k1
- self.hash() passing in the siphasher24 instance
- drop the 2 most significant bytes (to return a 6 byte short_id)