OwnedTxOut

Struct OwnedTxOut 

Source
pub struct OwnedTxOut<'a> { /* private fields */ }
Expand description

Transaction output that can be redeemed by a private key pair at a given index and are returned by the check_outputs method.

use monero::blockdata::transaction::Transaction;
use monero::consensus::encode::deserialize;
use monero::util::key::{KeyPair, PrivateKey, PublicKey, ViewPair};

// Keypair used to recover the ephemeral spend key of an output
let keypair = KeyPair {
    view: secret_view,
    spend: secret_spend,
};

// Viewpair used to scan a transaction to retreive owned outputs
let view_pair = ViewPair { view: secret_view, spend };

// Get all owned output for sub-addresses in range of 0-1 major index and 0-2 minor index
let owned_outputs = tx.check_outputs(&view_pair, 0..2, 0..3).unwrap();

for out in owned_outputs {
    // Recover the ephemeral private spend key
    let private_key = out.recover_key(&keypair);
}

Implementations§

Source§

impl<'a> OwnedTxOut<'a>

Source

pub fn index(&self) -> usize

Returns the index of this output in the transaction

Source

pub fn out(&self) -> &'a TxOut

Returns a reference to the actual redeemable output.

Source

pub fn sub_index(&self) -> Index

Returns the index of the key pair to use, can be 0/0 for main address.

Source

pub fn tx_pubkey(&self) -> PublicKey

Returns the associated transaction public key.

Source

pub fn amount(&self) -> Option<Amount>

Returns the unblinded or clear amount of this output.

None if we didn’t have enough information to unblind the output.

Source

pub fn blinding_factor(&self) -> Option<Scalar>

Returns the original blinding factor of this output.

None if we didn’t have enough information to unblind the output.

Source

pub fn commitment(&self) -> Option<EdwardsPoint>

Returns the original commitment of this output.

None if we didn’t have enough information to unblind the output.

Source

pub fn recover_key(&self, keys: &KeyPair) -> PrivateKey

Recover the ephemeral private key for spending the output, this requires access to the private spend key.

Trait Implementations§

Source§

impl<'a> Debug for OwnedTxOut<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for OwnedTxOut<'a>

§

impl<'a> RefUnwindSafe for OwnedTxOut<'a>

§

impl<'a> Send for OwnedTxOut<'a>

§

impl<'a> Sync for OwnedTxOut<'a>

§

impl<'a> Unpin for OwnedTxOut<'a>

§

impl<'a> UnwindSafe for OwnedTxOut<'a>

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, 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.
Source§

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

Source§

fn vzip(self) -> V