pub struct SignedContract { /* private fields */ }Expand description
Represents a fully signed and enforceable TicketedDLC, created
by running a SigningSession.
Implementations§
Source§impl SignedContract
impl SignedContract
Sourcepub fn all_signatures(&self) -> &ContractSignatures
pub fn all_signatures(&self) -> &ContractSignatures
Returns the complete set of signatures for all outcomes and win conditions.
Sourcepub fn pruned_signatures(
&self,
player_pubkey: Point,
) -> Option<ContractSignatures>
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.
Sourcepub fn dlc(&self) -> &TicketedDLC
pub fn dlc(&self) -> &TicketedDLC
Returns the TicketedDLC which has been signed.
Sourcepub fn params(&self) -> &ContractParameters
pub fn params(&self) -> &ContractParameters
Returns the contract parameters used to construct the DLC.
Sourcepub fn unsigned_outcome_tx<'a>(
&'a self,
outcome_index: OutcomeIndex,
) -> Option<&'a Transaction>
pub fn unsigned_outcome_tx<'a>( &'a self, outcome_index: OutcomeIndex, ) -> Option<&'a Transaction>
Return an unsigned outcome transaction.
Sourcepub fn signed_outcome_tx(
&self,
outcome_index: OutcomeIndex,
attestation: impl Into<MaybeScalar>,
) -> Result<Transaction, Error>
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.
Sourcepub fn expiry_tx(&self) -> Option<Transaction>
pub fn expiry_tx(&self) -> Option<Transaction>
Return the signed expiry transaction, if one exists for this contract.
Sourcepub fn unsigned_split_tx<'a>(
&'a self,
outcome: &Outcome,
) -> Option<&'a Transaction>
pub fn unsigned_split_tx<'a>( &'a self, outcome: &Outcome, ) -> Option<&'a Transaction>
Return the unsigned split transaction for the given outcome.
Sourcepub fn signed_split_tx(
&self,
win_cond: &WinCondition,
ticket_preimage: Preimage,
) -> Result<Transaction, Error>
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.
Sourcepub fn funding_close_tx_input_and_prevout(&self) -> (TxIn, TxOut)
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.
Sourcepub fn outcome_reclaim_tx_input_and_prevout<'a>(
&'a self,
outcome: &Outcome,
) -> Result<(TxIn, &'a TxOut), Error>
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.
Sourcepub fn outcome_close_tx_input_and_prevout<'a>(
&'a self,
outcome: &Outcome,
) -> Result<(TxIn, &'a TxOut), Error>
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.
Sourcepub fn split_win_tx_input_and_prevout<'a>(
&'a self,
win_cond: &WinCondition,
) -> Result<(TxIn, &'a TxOut), Error>
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.
Sourcepub fn split_reclaim_tx_input_and_prevout<'a>(
&'a self,
win_cond: &WinCondition,
) -> Result<(TxIn, &'a TxOut), Error>
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.
Sourcepub fn split_sellback_tx_input_and_prevout<'a>(
&'a self,
win_cond: &WinCondition,
) -> Result<(TxIn, &'a TxOut), Error>
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.
Sourcepub fn split_close_tx_input_and_prevout<'a>(
&'a self,
win_cond: &WinCondition,
) -> Result<(TxIn, &'a TxOut), Error>
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.
Sourcepub fn outcome_reclaim_tx_input_weight(
&self,
outcome: &Outcome,
) -> Option<InputWeightPrediction>
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.
Sourcepub fn split_win_tx_input_weight(&self) -> InputWeightPrediction
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.
Sourcepub fn split_reclaim_tx_input_weight(&self) -> InputWeightPrediction
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.
Sourcepub fn split_sellback_tx_input_weight(&self) -> InputWeightPrediction
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.
Sourcepub fn close_tx_input_weight(&self) -> InputWeightPrediction
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub 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>
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
impl Clone for SignedContract
Source§fn clone(&self) -> SignedContract
fn clone(&self) -> SignedContract
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more