Struct elements::TxOut

source ·
pub struct TxOut {
    pub asset: Asset,
    pub value: Value,
    pub nonce: Nonce,
    pub script_pubkey: Script,
    pub witness: TxOutWitness,
}
Expand description

Transaction output

Fields§

§asset: Asset

Committed asset

§value: Value

Committed amount

§nonce: Nonce

Nonce (ECDH key passed to recipient)

§script_pubkey: Script

Scriptpubkey

§witness: TxOutWitness

Witness data - not deserialized/serialized as part of a TxIn object (rather as part of its containing transaction, if any) but is logically part of the txin.

Implementations§

source§

impl TxOut

source

pub fn new_fee(amount: u64, asset: AssetId) -> TxOut

Create a new fee output.

source

pub fn is_null_data(&self) -> bool

Whether this data represents nulldata (OP_RETURN followed by pushes, not necessarily minimal)

source

pub fn is_pegout(&self) -> bool

Whether this output is a pegout, which is a subset of nulldata with the following extra rules: (a) there must be at least 2 pushes, the first of which must be 32 bytes and the second of which must be nonempty; (b) all pushes must use a push opcode rather than a numeric or reserved opcode

source

pub fn pegout_data(&self) -> Option<PegoutData<'_>>

If this output is a pegout, returns the destination genesis block, the destination script pubkey, and any additional data

source

pub fn is_fee(&self) -> bool

Whether or not this output is a fee output

source

pub fn minimum_value(&self) -> u64

Extracts the minimum value from the rangeproof, if there is one, or returns 0.

source

pub fn is_partially_blinded(&self) -> bool

Returns if at least some part of this output are blinded

source§

impl TxOut

source

pub const RANGEPROOF_MIN_VALUE: u64 = 1u64

Rangeproof minimum value

source

pub const RANGEPROOF_EXP_SHIFT: i32 = 0i32

Rangeproof exponent shift

source

pub const RANGEPROOF_MIN_PRIV_BITS: u8 = 52u8

Rangeproof Minimum private bits

source

pub const MAX_MONEY: u64 = 2_100_000_000_000_000u64

Maximum explicit amount in a bitcoin TxOut

source

pub fn new_not_last_confidential<R, C, S>( rng: &mut R, secp: &Secp256k1<C>, value: u64, address: Address, asset: AssetId, spent_utxo_secrets: &[S] ) -> Result<(Self, AssetBlindingFactor, ValueBlindingFactor, SecretKey), ConfidentialTxOutError>
where R: RngCore + CryptoRng, C: Signing, S: Into<SurjectionInput> + Copy,

Creates a new confidential output that is not the last one in the transaction. Provide input secret information by creating SurjectionInput for each input. Inputs for issuances must be provided in the followed by inputs for input asset.

For example, if the second input contains non-null issuance and re-issuance tokens, the spent_utxo_secrets should be of the form [inp_1, inp_2, inp_2_issue, inp2_reissue,…]

If the issuance or re-issuance is null, it should not be added to spent_utxo_secrets

§Returns:

A tuple of (TxOut, AssetBlindingFactor, ValueBlindingFactor, ephemeral secret key [SecretKey]) sampled from the given rng

source

pub fn with_txout_secrets<R, C, S>( rng: &mut R, secp: &Secp256k1<C>, spk: Script, receiver_blinding_pk: PublicKey, ephemeral_sk: SecretKey, out_secrets: TxOutSecrets, spent_utxo_secrets: &[S] ) -> Result<Self, ConfidentialTxOutError>
where R: RngCore + CryptoRng, C: Signing, S: Into<SurjectionInput> + Copy,

Similar to TxOut::new_not_last_confidential, but takes input the asset, value blinding factors and ephemeral secret key instead of sampling them from rng. The rng is only used in surjection proof creation while selecting inputs

Use the txout_secrets to specify the secrets to use while creating this output. Use the ValueBlindingFactor::last method to compute the blinding factor for the last input.

source

pub fn to_non_last_confidential<R, C, S>( &self, rng: &mut R, secp: &Secp256k1<C>, blinder: PublicKey, spent_utxo_secrets: &[S] ) -> Result<(TxOut, AssetBlindingFactor, ValueBlindingFactor, SecretKey), ConfidentialTxOutError>
where R: RngCore + CryptoRng, C: Signing, S: Into<SurjectionInput> + Copy,

Convert a explicit TxOut into a Confidential TxOut. The blinding key is provided by the blinder parameter. The initial value of nonce is ignored and is set to the ECDH pubkey sampled by the sender.

§Returns:

A tuple of (AssetBlindingFactor, ValueBlindingFactor, ephemeral secret key [SecretKey]) sampled from the given rng

source

pub fn new_last_confidential<R, C>( rng: &mut R, secp: &Secp256k1<C>, value: u64, asset: AssetId, spk: Script, blinder: PublicKey, spent_utxo_secrets: &[TxOutSecrets], output_secrets: &[&TxOutSecrets] ) -> Result<(Self, AssetBlindingFactor, ValueBlindingFactor, SecretKey), ConfidentialTxOutError>
where R: RngCore + CryptoRng, C: Signing,

Creates a new confidential output that IS the last one in the transaction.

Inputs for issuances must be provided in the followed by inputs for input asset. For example, if the second input contains non-null issuance and re-issuance tokens, the spent_utxo_secrets should be of the form [inp_1, inp_2, inp_2_issue, inp2_reissue,…] If the issuance or re-issuance is null, it should not be added to spent_utxo_secrets

§Returns:

A tuple of (AssetBlindingFactor, ValueBlindingFactor, ephemeral secret key [SecretKey]) sampled from the given rng

source

pub fn with_secrets_last<R, C>( rng: &mut R, secp: &Secp256k1<C>, value: u64, spk: Script, blinder: PublicKey, asset: AssetId, ephemeral_sk: SecretKey, out_abf: AssetBlindingFactor, spent_utxo_secrets: &[TxOutSecrets], output_secrets: &[&TxOutSecrets] ) -> Result<(Self, ValueBlindingFactor), ConfidentialTxOutError>
where R: RngCore + CryptoRng, C: Signing,

Similar to TxOut::new_last_confidential, but allows specifying the asset blinding factor and the ephemeral key. The value-blinding factor is computed adaptively

source

pub fn unblind<C: Verification>( &self, secp: &Secp256k1<C>, blinding_key: SecretKey ) -> Result<TxOutSecrets, UnblindError>

Unblinds a transaction output, if it is confidential.

It returns the secret elements of the value and asset Pedersen commitments.

Trait Implementations§

source§

impl Clone for TxOut

source§

fn clone(&self) -> TxOut

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 TxOut

source§

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

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

impl Decodable for TxOut

source§

fn consensus_decode<D: Read>(d: D) -> Result<TxOut, Error>

Decode an object with a well-defined format
source§

impl Default for TxOut

source§

fn default() -> TxOut

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

impl Deserialize for TxOut

source§

fn deserialize(bytes: &[u8]) -> Result<Self, Error>

Deserialize a value from raw data.
source§

impl Encodable for TxOut

source§

fn consensus_encode<S: Write>(&self, s: S) -> Result<usize, Error>

Encode an object with a well-defined format, should only ever error if the underlying Write errors. Returns the number of bytes written on success
source§

impl Hash for TxOut

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for TxOut

source§

fn cmp(&self, other: &TxOut) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for TxOut

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for TxOut

source§

fn partial_cmp(&self, other: &TxOut) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for TxOut

source§

fn serialize(&self) -> Vec<u8>

Serialize a value as raw data.
source§

impl Eq for TxOut

source§

impl StructuralPartialEq for TxOut

Auto Trait Implementations§

§

impl RefUnwindSafe for TxOut

§

impl Send for TxOut

§

impl Sync for TxOut

§

impl Unpin for TxOut

§

impl UnwindSafe for TxOut

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

source§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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