Struct elements::pset::PartiallySignedTransaction
source · pub struct PartiallySignedTransaction {
pub global: Global,
/* private fields */
}Expand description
A Partially Signed Transaction.
Fields§
§global: GlobalThe key-value pairs for all global data.
Implementations§
source§impl PartiallySignedTransaction
impl PartiallySignedTransaction
Contains extension to add and retrieve from the PSET contract informations related to an asset
sourcepub fn add_asset_metadata(
&mut self,
asset_id: AssetId,
asset_meta: &AssetMetadata,
) -> Option<Result<AssetMetadata, Error>>
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
sourcepub fn get_asset_metadata(
&self,
asset_id: AssetId,
) -> Option<Result<AssetMetadata, Error>>
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
sourcepub fn add_token_metadata(
&mut self,
token_id: AssetId,
token_meta: &TokenMetadata,
) -> Option<Result<TokenMetadata, Error>>
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
sourcepub fn get_token_metadata(
&self,
token_id: AssetId,
) -> Option<Result<TokenMetadata, Error>>
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
impl PartiallySignedTransaction
sourcepub fn from_tx(tx: Transaction) -> Self
pub fn from_tx(tx: Transaction) -> Self
Create a new PSET from a raw transaction
sourcepub fn new_v2() -> Self
pub fn new_v2() -> Self
Create a PartiallySignedTransaction with zero inputs zero outputs with a version 2 and tx version 2
sourcepub fn add_input(&mut self, inp: Input)
pub fn add_input(&mut self, inp: Input)
Add an input to pset. This also updates the pset global input count
sourcepub fn insert_input(&mut self, inp: Input, pos: usize)
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.
sourcepub fn inputs_mut(&mut self) -> &mut [Input]
pub fn inputs_mut(&mut self) -> &mut [Input]
Mutable accessor to inputs
sourcepub fn remove_input(&mut self, index: usize) -> Option<Input>
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
sourcepub fn add_output(&mut self, out: Output)
pub fn add_output(&mut self, out: Output)
Add an output to pset. This also updates the pset global output count
sourcepub fn insert_output(&mut self, out: Output, pos: usize)
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.
sourcepub fn outputs_mut(&mut self) -> &mut [Output]
pub fn outputs_mut(&mut self) -> &mut [Output]
mutable accessor to outputs
sourcepub fn remove_output(&mut self, index: usize) -> Option<Output>
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
sourcepub fn locktime(&self) -> Result<LockTime, Error>
pub fn locktime(&self) -> Result<LockTime, Error>
Accessor for the locktime to be used in the final transaction
sourcepub fn unique_id(&self) -> Result<Txid, Error>
pub fn unique_id(&self) -> Result<Txid, Error>
Accessor for the “unique identifier” of this PSET, to be used when merging
sourcepub fn sanity_check(&self) -> Result<(), Error>
pub fn sanity_check(&self) -> Result<(), Error>
Sanity check input and output count
sourcepub fn extract_tx(&self) -> Result<Transaction, Error>
pub fn extract_tx(&self) -> Result<Transaction, Error>
Extract the Transaction from a PartiallySignedTransaction by filling in the available signature information in place.
sourcepub fn merge(&mut self, other: Self) -> Result<(), Error>
pub fn merge(&mut self, other: Self) -> Result<(), Error>
Attempt to merge with another PartiallySignedTransaction.
sourcepub fn surjection_inputs(
&self,
inp_txout_sec: &HashMap<usize, TxOutSecrets>,
) -> Result<Vec<SurjectionInput>, PsetBlindError>
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.
sourcepub 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>
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
- The blinder_index must be set in pset output field
- the corresponding inp_secrets[out.blinder_index] must be present
Issuances and re-issuance inputs are not blinded.
§Parameters
inp_secrets:TxOutSecretscorresponding to owned inputs. UseNonefor non-owned outputs
sourcepub fn blind_last<C: Signing, R: RngCore + CryptoRng>(
&mut self,
rng: &mut R,
secp: &Secp256k1<C>,
inp_txout_sec: &HashMap<usize, TxOutSecrets>,
) -> Result<(), PsetBlindError>
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:TxOutSecretscorresponding to owned inputs. UseNonefor non-owned outputs
Trait Implementations§
source§impl Clone for PartiallySignedTransaction
impl Clone for PartiallySignedTransaction
source§fn clone(&self) -> PartiallySignedTransaction
fn clone(&self) -> PartiallySignedTransaction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for PartiallySignedTransaction
impl Debug for PartiallySignedTransaction
source§impl Default for PartiallySignedTransaction
impl Default for PartiallySignedTransaction
impl StructuralPartialEq for PartiallySignedTransaction
Auto Trait Implementations§
impl Freeze for PartiallySignedTransaction
impl RefUnwindSafe for PartiallySignedTransaction
impl Send for PartiallySignedTransaction
impl Sync for PartiallySignedTransaction
impl Unpin for PartiallySignedTransaction
impl UnwindSafe for PartiallySignedTransaction
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)