SignedContract

Struct SignedContract 

Source
pub struct SignedContract { /* private fields */ }
Expand description

Represents a fully signed and enforceable TicketedDLC, created by running a SigningSession.

Implementations§

Source§

impl SignedContract

Source

pub fn all_signatures(&self) -> &ContractSignatures

Returns the complete set of signatures for all outcomes and win conditions.

Source

pub fn pruned_signatures( &self, player_pubkey: Point, ) -> Option<ContractSignatures>

Produce a pruned set of signatures, relevant to the specific signer’s pubkey. If the pubkey belongs to the market maker, this simply returns a clone of the full set of signatures, since the market maker is involved in every multisignature spending condition.

This method is used to reduce bandwidth requirements when transmitting aggregated signatures to players.

Source

pub fn dlc(&self) -> &TicketedDLC

Returns the TicketedDLC which has been signed.

Source

pub fn params(&self) -> &ContractParameters

Returns the contract parameters used to construct the DLC.

Source

pub fn unsigned_outcome_tx<'a>( &'a self, outcome_index: OutcomeIndex, ) -> Option<&'a Transaction>

Return an unsigned outcome transaction.

Source

pub fn signed_outcome_tx( &self, outcome_index: OutcomeIndex, attestation: impl Into<MaybeScalar>, ) -> Result<Transaction, Error>

Return a signed outcome transaction given the oracle’s attestation to a specific outcome.

Source

pub fn expiry_tx(&self) -> Option<Transaction>

Return the signed expiry transaction, if one exists for this contract.

Source

pub fn unsigned_split_tx<'a>( &'a self, outcome: &Outcome, ) -> Option<&'a Transaction>

Return the unsigned split transaction for the given outcome.

Source

pub fn signed_split_tx( &self, win_cond: &WinCondition, ticket_preimage: Preimage, ) -> Result<Transaction, Error>

Return a signed split transaction, given the ticket preimage for a specific player.

Source

pub fn funding_close_tx_input_and_prevout(&self) -> (TxIn, TxOut)

Returns prevout information for the market maker to create and sign a funding-close transaction.

See SignedContract::sign_funding_close_tx_input for more info on the funding-close TX.

Source

pub fn outcome_reclaim_tx_input_and_prevout<'a>( &'a self, outcome: &Outcome, ) -> Result<(TxIn, &'a TxOut), Error>

Returns prevout information for the market maker to create and sign an outcome-reclaim transaction.

See SignedContract::sign_outcome_reclaim_tx_input for more info on the outcome-reclaim TX.

Source

pub fn outcome_close_tx_input_and_prevout<'a>( &'a self, outcome: &Outcome, ) -> Result<(TxIn, &'a TxOut), Error>

Returns prevout information for the market maker to create and sign an outcome-close transaction.

See SignedContract::sign_outcome_close_tx_input for more info on the outcome-close TX.

Source

pub fn split_win_tx_input_and_prevout<'a>( &'a self, win_cond: &WinCondition, ) -> Result<(TxIn, &'a TxOut), Error>

Returns prevout information for a player to create and sign a split-win transaction.

See SignedContract::sign_split_win_tx_input for more info on the split-win TX.

Source

pub fn split_reclaim_tx_input_and_prevout<'a>( &'a self, win_cond: &WinCondition, ) -> Result<(TxIn, &'a TxOut), Error>

Returns prevout information for the market maker to create and sign a split-reclaim transaction.

See SignedContract::sign_split_reclaim_tx_input for more info on the split-reclaim TX.

Source

pub fn split_sellback_tx_input_and_prevout<'a>( &'a self, win_cond: &WinCondition, ) -> Result<(TxIn, &'a TxOut), Error>

Returns prevout information for the market maker to create and sign a split-sellback transaction.

See SignedContract::sign_split_sellback_tx_input for more info on the split-sellback TX.

Source

pub fn split_close_tx_input_and_prevout<'a>( &'a self, win_cond: &WinCondition, ) -> Result<(TxIn, &'a TxOut), Error>

Returns prevout information for the market maker to create and sign a split-close transaction.

See SignedContract::sign_split_close_tx_input for more info on the split-close TX.

Source

pub fn outcome_reclaim_tx_input_weight( &self, outcome: &Outcome, ) -> Option<InputWeightPrediction>

Returns an input weight prediction value for the witnessed input of an outcome-reclaim TX, which reclaims funds from the given outcome’s outcome TX.

See SignedContract::sign_outcome_reclaim_tx_input for more info on the outcome-reclaim TX.

Source

pub fn split_win_tx_input_weight(&self) -> InputWeightPrediction

Returns an input weight prediction value for the witnessed input of a split-win TX. All split-win TX inputs have the same weight.

See SignedContract::sign_split_win_tx_input for more info on the split-win TX.

Source

pub fn split_reclaim_tx_input_weight(&self) -> InputWeightPrediction

Returns an input weight prediction value for the witnessed input of a split-reclaim TX. All split-reclaim TX inputs have the same weight.

See SignedContract::sign_split_reclaim_tx_input for more info on the split-reclaim TX.

TODO: this should be a constant covered by tests.

Source

pub fn split_sellback_tx_input_weight(&self) -> InputWeightPrediction

Returns an input weight prediction value for the witnessed input of a split-sellback TX. All split-sellback TX inputs have the same weight.

See SignedContract::sign_split_sellback_tx_input for more info on the split-sellback TX.

TODO: this should be a constant covered by tests.

Source

pub fn close_tx_input_weight(&self) -> InputWeightPrediction

Returns an input weight prediction value for the witnessed input of a close TX (any close TX). All close TX inputs have the same weight, which is InputWeightPrediction::P2TR_KEY_DEFAULT_SIGHASH.

See SignedContract::sign_funding_close_tx_input for more info on the funding-close TX. See SignedContract::sign_outcome_close_tx_input for more info on the outcome-close TX. See SignedContract::sign_split_close_tx_input for more info on the split-close TX.

TODO: this should be a constant alias.

Source

pub fn sign_outcome_reclaim_tx_input<T: Borrow<TxOut>>( &self, outcome: &Outcome, reclaim_tx: &mut Transaction, input_index: usize, prevouts: &Prevouts<'_, T>, market_maker_secret_key: impl Into<Scalar>, ) -> Result<(), Error>

Sign an outcome-reclaim transaction which spends the outcome TX output to the control of the market maker.

The outcome-reclaim TX should be used if none of the outcome winners purchased their ticket preimage, and so the market maker can reclaim his money before the split transaction splits it into multiple smaller UTXOs.

The market maker can only publish an outcome-reclaim TX once the outcome transaction has at least 2 * relative_locktime_block_delta confirmations.

Source

pub fn sign_funding_close_tx_input<T: Borrow<TxOut>>( &self, close_tx: &mut Transaction, input_index: usize, prevouts: &Prevouts<'_, T>, market_maker_secret_key: impl Into<Scalar>, player_secret_keys: &BTreeMap<Point, Scalar>, ) -> Result<(), Error>

Sign a cooperative closing transaction which spends the funding transaction output back to the market maker’s control.

The funding-close TX should be used if all ticket-bearing winners have been paid out-of-band, and all players including non-winners are cooperative. Once the winners have their payouts, they can send their secret keys to the market maker to let him reclaim all the on-chain capital. Non-winners, once they realize they are not in a position to earn any money from the DLC, can surrender their secret keys to the market maker to cooperate and thereby enable the most efficient possible on-chain resolution of the DLC.

The market maker can only publish a funding-close TX once all players including non-winners have given the market maker their secret keys, which they should only do if they have been paid out completely, or won’t be paid out ever.

Source

pub fn sign_outcome_close_tx_input<T: Borrow<TxOut>>( &self, outcome: &Outcome, close_tx: &mut Transaction, input_index: usize, prevouts: &Prevouts<'_, T>, market_maker_secret_key: impl Into<Scalar>, player_secret_keys: &BTreeMap<Point, Scalar>, ) -> Result<(), Error>

Sign a cooperative closing transaction which spends the outcome transaction output back to the market maker’s control.

The outcome-close TX should be used when all outcome winners purchased their ticket preimage, and the market maker has paid each winner their winnings out-of-band.

The market maker can use this method once they have issued off-chain payouts to all winning players for an outcome. Once the players have their payouts, they can send their secret keys to the market maker to let him reclaim all the on-chain capital.

The market maker can only publish an outcome-close TX once all winning players have given the market maker their secret keys, which they should only do if they have been paid out completely.

Source

pub fn sign_split_win_tx_input<T: Borrow<TxOut>>( &self, win_cond: &WinCondition, win_tx: &mut Transaction, input_index: usize, prevouts: &Prevouts<'_, T>, ticket_preimage: Preimage, player_secret_key: impl Into<Scalar>, ) -> Result<(), Error>

Sign a transaction which spends a split transaction output to the control of a player who must know their ticket preimage.

The split-win TX should be used by a player to enforce the outcome payout on-chain. Ideally, players would be paid out off-chain or using cross-chain HTLCs. However, the split-win TX is the fallback option which guarantees a player receives a majority of their payout (minus mining fees).

The player can only publish a split-win TX once the split transaction has at least relative_locktime_block_delta confirmations.

Source

pub fn sign_split_reclaim_tx_input<T: Borrow<TxOut>>( &self, win_cond: &WinCondition, reclaim_tx: &mut Transaction, input_index: usize, prevouts: &Prevouts<'_, T>, market_maker_secret_key: impl Into<Scalar>, ) -> Result<(), Error>

Signs a transaction which spends a split transaction output to the market maker’s control.

The split-reclaim TX should be used by the market maker if a specific player did not buy their ticket preimage, and so the market maker can reclaim the winnings himself.

The market maker can only publish a split-reclaim TX once the split transaction has at least 2 * relative_locktime_block_delta confirmations.

Source

pub fn sign_split_sellback_tx_input<T: Borrow<TxOut>>( &self, win_cond: &WinCondition, sellback_tx: &mut Transaction, input_index: usize, prevouts: &Prevouts<'_, T>, payout_preimage: Preimage, market_maker_secret_key: impl Into<Scalar>, ) -> Result<(), Error>

Signs a transaction which spends a split transaction output to the market maker’s control.

A split-sellback TX should be used when an outcome winner purchased their ticket preimage, and the market maker has paid the winner their winnings out-of-band in exchange for the player’s payout preimage.

The market maker can only publish a split-sellback TX once a player has given the market maker their payout preimage, which they should only do if they have been paid out completely.

The only distinction between a split-sellback and a split-close TX is whether the market maker has been given the player’s signing key. If so, then the market maker should use the split-close TX because it is more efficient and private than the split-sellback TX.

Source

pub fn sign_split_close_tx_input<T: Borrow<TxOut>>( &self, win_cond: &WinCondition, close_tx: &mut Transaction, input_index: usize, prevouts: &Prevouts<'_, T>, market_maker_secret_key: impl Into<Scalar>, player_secret_key: impl Into<Scalar>, ) -> Result<(), Error>

Sign a cooperative closing transaction which spends a player’s split transaction output.

The split-close TX should be used when an outcome winner purchased their ticket preimage, and the market maker has paid the winner their winnings out-of-band.

The market maker can use this method once they have issued off-chain payouts to this winning player. Once the player has her off-chain payout, she can send their secret key to the market maker to let him reclaim all the on-chain capital efficiently.

The market maker can only publish a split-close TX once a player has given the market maker their secret key, which they should only do if they have been paid out completely.

The only distinction between a split-sellback and a split-close TX is whether the market maker has been given the player’s signing key. If so, then the market maker should use the split-close TX because it is more efficient and private than the split-sellback TX.

Trait Implementations§

Source§

impl Clone for SignedContract

Source§

fn clone(&self) -> SignedContract

Returns a duplicate 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 SignedContract

Source§

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

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

impl<'de> Deserialize<'de> for SignedContract

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SignedContract

Source§

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

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for SignedContract

Source§

impl StructuralPartialEq for SignedContract

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, dest: *mut u8)

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

Source§

type Output = T

Should always be Self
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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,