Struct themelio_structs::Transaction
source · pub struct Transaction {
pub kind: TxKind,
pub inputs: Vec<CoinID>,
pub outputs: Vec<CoinData>,
pub fee: CoinValue,
pub covenants: Vec<Vec<u8>>,
pub data: Vec<u8>,
pub sigs: Vec<Vec<u8>>,
}Expand description
Transaction represents an individual, serializable Themelio transaction.
Fields§
§kind: TxKind§inputs: Vec<CoinID>§outputs: Vec<CoinData>§fee: CoinValue§covenants: Vec<Vec<u8>>§data: Vec<u8>§sigs: Vec<Vec<u8>>Implementations§
source§impl Transaction
impl Transaction
sourcepub fn empty_test() -> Self
pub fn empty_test() -> Self
An empty transaction with kind Normal, no inputs, no fees, etc.
sourcepub fn new(kind: TxKind) -> Self
pub fn new(kind: TxKind) -> Self
Creates a new transaction with the given kind, no inputs, no outputs, no nothing.
sourcepub fn with_inputs(self, inputs: Vec<CoinID>) -> Self
pub fn with_inputs(self, inputs: Vec<CoinID>) -> Self
Replaces the inputs of the transaction
sourcepub fn with_outputs(self, outputs: Vec<CoinData>) -> Self
pub fn with_outputs(self, outputs: Vec<CoinData>) -> Self
Replaces the outputs of the transaction
sourcepub fn add_output(self, output: CoinData) -> Self
pub fn add_output(self, output: CoinData) -> Self
Add an output
sourcepub fn with_scripts(self, scripts: Vec<Vec<u8>>) -> Self
pub fn with_scripts(self, scripts: Vec<Vec<u8>>) -> Self
Replaces the scripts of the transaction
sourcepub fn add_script(self, script: Vec<u8>) -> Self
pub fn add_script(self, script: Vec<u8>) -> Self
Add a script to the transaction
sourcepub fn is_well_formed(&self) -> bool
pub fn is_well_formed(&self) -> bool
Checks whether or not the transaction is well formed, respecting coin size bounds and such. Does not fully validate the transaction.
sourcepub fn hash_nosigs(&self) -> TxHash
pub fn hash_nosigs(&self) -> TxHash
hash_nosigs returns the hash of the transaction with a zeroed-out signature field. This is what signatures are computed against.
sourcepub fn signed_ed25519(self, sk: Ed25519SK) -> Self
pub fn signed_ed25519(self, sk: Ed25519SK) -> Self
sign_ed25519 consumes the transaction, appends an ed25519 signature, and returns it.
sourcepub fn total_outputs(&self) -> HashMap<Denom, CoinValue>
pub fn total_outputs(&self) -> HashMap<Denom, CoinValue>
total_outputs returns a HashMap mapping each type of coin to its total value. Fees will be included in the Mel cointype.
sourcepub fn covenants_as_map(&self) -> HashMap<Address, Vec<u8>>
pub fn covenants_as_map(&self) -> HashMap<Address, Vec<u8>>
scripts_as_map returns a HashMap mapping the hash of each script in the transaction to the script itself.
sourcepub fn base_fee(
&self,
fee_multiplier: u128,
ballast: u128,
cov_to_weight: impl Fn(&[u8]) -> u128
) -> CoinValue
pub fn base_fee(
&self,
fee_multiplier: u128,
ballast: u128,
cov_to_weight: impl Fn(&[u8]) -> u128
) -> CoinValue
Returns the minimum fee of the transaction at a given fee multiplier, with a given “ballast”.
sourcepub fn weight(&self, cov_to_weight: impl Fn(&[u8]) -> u128) -> u128
pub fn weight(&self, cov_to_weight: impl Fn(&[u8]) -> u128) -> u128
Returns the weight of the transaction, given a function that maps a covenant to its weight.
sourcepub fn output_coinid(&self, index: u8) -> CoinID
pub fn output_coinid(&self, index: u8) -> CoinID
Convenience function that constructs a CoinID that points to a certain output of this transaction. Panics if the index is out of bounds.
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for Transaction
impl<'arbitrary> Arbitrary<'arbitrary> for Transaction
source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moresource§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 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 Hash for Transaction
impl Hash for Transaction
source§impl PartialEq<Transaction> for Transaction
impl PartialEq<Transaction> for Transaction
source§fn eq(&self, other: &Transaction) -> bool
fn eq(&self, other: &Transaction) -> bool
source§impl Serialize for Transaction
impl Serialize for Transaction
impl Eq for Transaction
impl StructuralEq for Transaction
impl StructuralPartialEq for Transaction
Auto Trait Implementations§
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> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self, then passes self.as_ref() into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
source§impl<T> StdcodeSerializeExt for Twhere
T: Serialize,
impl<T> StdcodeSerializeExt for Twhere
T: Serialize,
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B> of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B> of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R> view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R> view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds. Read moresource§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow() only in debug builds, and is erased in release
builds. Read moresource§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut() only in debug builds, and is erased in release
builds. Read moresource§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref() only in debug builds, and is erased in release
builds. Read moresource§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut() only in debug builds, and is erased in release
builds. Read more