Struct elements::pset::PartiallySignedTransaction

source ·
pub struct PartiallySignedTransaction {
    pub global: Global,
    /* private fields */
}
Expand description

A Partially Signed Transaction.

Fields§

§global: Global

The key-value pairs for all global data.

Implementations§

source§

impl PartiallySignedTransaction

Contains extension to add and retrieve from the PSET contract informations related to an asset

source

pub fn add_asset_metadata( &mut self, asset_id: AssetId, asset_meta: &AssetMetadata, ) -> Option<Result<AssetMetadata, Error>>

Add contract information to the PSET, returns None if it wasn’t present or Some with the old data if already in the PSET

source

pub fn get_asset_metadata( &self, asset_id: AssetId, ) -> Option<Result<AssetMetadata, Error>>

Get contract information from the PSET, returns None if there are no information regarding the given `asset_id`` in the PSET

source

pub fn add_token_metadata( &mut self, token_id: AssetId, token_meta: &TokenMetadata, ) -> Option<Result<TokenMetadata, Error>>

Add token information to the PSET, returns None if it wasn’t present or Some with the old data if already in the PSET

source

pub fn get_token_metadata( &self, token_id: AssetId, ) -> Option<Result<TokenMetadata, Error>>

Get token information from the PSET, returns None if there are no information regarding the given `token_id`` in the PSET

source§

impl PartiallySignedTransaction

source

pub fn from_tx(tx: Transaction) -> Self

Create a new PSET from a raw transaction

source

pub fn new_v2() -> Self

Create a PartiallySignedTransaction with zero inputs zero outputs with a version 2 and tx version 2

source

pub fn add_input(&mut self, inp: Input)

Add an input to pset. This also updates the pset global input count

source

pub fn insert_input(&mut self, inp: Input, pos: usize)

Add an input to pset at position i. This also updates the pset global input count and the blinder index that might have shifted.

See also: PartiallySignedTransaction::add_input Panics if index is more than length.

source

pub fn inputs(&self) -> &[Input]

Read accessor to inputs

source

pub fn inputs_mut(&mut self) -> &mut [Input]

Mutable accessor to inputs

source

pub fn remove_input(&mut self, index: usize) -> Option<Input>

Remove the input at index and return it if any, otherwise returns None This also updates the pset global input count

source

pub fn add_output(&mut self, out: Output)

Add an output to pset. This also updates the pset global output count

source

pub fn insert_output(&mut self, out: Output, pos: usize)

Add an output to pset at position i. This also updates the pset global output count Panics if index is more than length.

source

pub fn outputs(&self) -> &[Output]

read accessor to outputs

source

pub fn outputs_mut(&mut self) -> &mut [Output]

mutable accessor to outputs

source

pub fn remove_output(&mut self, index: usize) -> Option<Output>

Remove the output at index and return it if any, otherwise returns None This also updates the pset global output count

source

pub fn n_inputs(&self) -> usize

Accessor for the number of inputs currently in the PSET

source

pub fn n_outputs(&self) -> usize

Accessor for the number of outputs currently in the PSET

source

pub fn locktime(&self) -> Result<LockTime, Error>

Accessor for the locktime to be used in the final transaction

source

pub fn unique_id(&self) -> Result<Txid, Error>

Accessor for the “unique identifier” of this PSET, to be used when merging

source

pub fn sanity_check(&self) -> Result<(), Error>

Sanity check input and output count

source

pub fn extract_tx(&self) -> Result<Transaction, Error>

Extract the Transaction from a PartiallySignedTransaction by filling in the available signature information in place.

source

pub fn merge(&mut self, other: Self) -> Result<(), Error>

Attempt to merge with another PartiallySignedTransaction.

source

pub fn surjection_inputs( &self, inp_txout_sec: &HashMap<usize, TxOutSecrets>, ) -> Result<Vec<SurjectionInput>, PsetBlindError>

Obtains the surjection inputs for this pset. This servers as the domain when creating a new SurjectionProof. Informally, the domain refers to the set of inputs assets. For inputs whose TxOutSecrets is supplied, SurjectionInput::Known variant is created. For confidential inputs whose secrets are not supplied SurjectionInput::Unknown variant is created. For non-confidential inputs, SurjectionInput::Known variant is created with zero blinding factors.

source

pub fn blind_non_last<C: Signing, R: RngCore + CryptoRng>( &mut self, rng: &mut R, secp: &Secp256k1<C>, inp_txout_sec: &HashMap<usize, TxOutSecrets>, ) -> Result<Vec<(AssetBlindingFactor, ValueBlindingFactor)>, PsetBlindError>

Blind the pset as the non-last blinder role. The last blinder of pset should call the blind_last function which balances the blinding factors inp_secrets and must be consistent by Output blinder_index field For each output that is to be blinded, the following must be true

  1. The blinder_index must be set in pset output field
  2. the corresponding inp_secrets[out.blinder_index] must be present

Issuances and re-issuance inputs are not blinded.

§Parameters
  • inp_secrets: TxOutSecrets corresponding to owned inputs. Use None for non-owned outputs
source

pub fn blind_last<C: Signing, R: RngCore + CryptoRng>( &mut self, rng: &mut R, secp: &Secp256k1<C>, inp_txout_sec: &HashMap<usize, TxOutSecrets>, ) -> Result<(), PsetBlindError>

Blind the pset as the last blinder role. The non-last blinder of pset should call the Self::blind_non_last function. This function balances the blinding factors with partial information about blinding inputs and scalars from Global scalars field. inp_secrets and out_secrets must be consistent by Output blinder_index field For each output, the corresponding inp_secrets[out.blinder_index] must be present

§Parameters
  • inp_secrets: TxOutSecrets corresponding to owned inputs. Use None for non-owned outputs

Trait Implementations§

source§

impl Clone for PartiallySignedTransaction

source§

fn clone(&self) -> PartiallySignedTransaction

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 PartiallySignedTransaction

source§

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

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

impl Decodable for PartiallySignedTransaction

source§

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

Decode an object with a well-defined format
source§

impl Default for PartiallySignedTransaction

source§

fn default() -> Self

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

impl Encodable for PartiallySignedTransaction

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 PartialEq for PartiallySignedTransaction

source§

fn eq(&self, other: &PartiallySignedTransaction) -> 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 StructuralPartialEq for PartiallySignedTransaction

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

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