mirror of
https://github.com/conduition/dlctix.git
synced 2026-01-29 20:55:10 +01:00
add OutcomeIndex alias for outcome indexes
This commit is contained in:
@@ -19,6 +19,10 @@ use std::collections::{BTreeMap, BTreeSet};
|
||||
/// index in the sorted set of players.
|
||||
pub type PlayerIndex = usize;
|
||||
|
||||
/// A type alias for clarity. Players in the DLC are often referred to by their
|
||||
/// index in the sorted set of players.
|
||||
pub type OutcomeIndex = usize;
|
||||
|
||||
/// Represents a mapping of player to payout weight for a given outcome.
|
||||
///
|
||||
/// A player's payout under an outcome is proportional to the size of their payout weight
|
||||
@@ -82,7 +86,7 @@ pub struct ContractParameters {
|
||||
#[derive(Clone, Copy, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
||||
pub enum Outcome {
|
||||
/// Indicates the oracle attested to a particular outcome of the given index.
|
||||
Attestation(usize),
|
||||
Attestation(OutcomeIndex),
|
||||
|
||||
/// Indicates the oracle failed to attest to any outcome, and the event expiry
|
||||
/// timelock was reached.
|
||||
|
||||
@@ -8,7 +8,7 @@ use secp::{Point, Scalar};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use crate::{
|
||||
contract::{ContractParameters, Outcome},
|
||||
contract::{ContractParameters, Outcome, OutcomeIndex},
|
||||
errors::Error,
|
||||
spend_info::{FundingSpendInfo, OutcomeSpendInfo},
|
||||
};
|
||||
@@ -226,7 +226,7 @@ pub(crate) fn verify_outcome_tx_partial_signatures(
|
||||
pub(crate) struct OutcomeSignatures {
|
||||
/// A set of adaptor signatures which can be unlocked by the oracle's attestation
|
||||
/// for each outcome.
|
||||
pub(crate) outcome_tx_signatures: BTreeMap<usize, AdaptorSignature>,
|
||||
pub(crate) outcome_tx_signatures: BTreeMap<OutcomeIndex, AdaptorSignature>,
|
||||
|
||||
/// The complete signature on the expiry transaction. This is `None` if the
|
||||
/// [`ContractParameters::outcome_payouts`] field does not contain an
|
||||
@@ -312,7 +312,7 @@ pub(crate) fn verify_outcome_tx_aggregated_signatures(
|
||||
params: &ContractParameters,
|
||||
our_pubkey: Point,
|
||||
outcome_build_out: &OutcomeTransactionBuildOutput,
|
||||
outcome_tx_signatures: &BTreeMap<usize, AdaptorSignature>,
|
||||
outcome_tx_signatures: &BTreeMap<OutcomeIndex, AdaptorSignature>,
|
||||
expiry_tx_signature: Option<CompactSignature>,
|
||||
) -> Result<(), Error> {
|
||||
let funding_spend_info = &outcome_build_out.funding_spend_info;
|
||||
|
||||
11
src/lib.rs
11
src/lib.rs
@@ -27,7 +27,7 @@ use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
};
|
||||
|
||||
pub use contract::{ContractParameters, Outcome, PlayerIndex, SigMap, WinCondition};
|
||||
pub use contract::{ContractParameters, Outcome, OutcomeIndex, PlayerIndex, SigMap, WinCondition};
|
||||
pub use oracles::EventAnnouncement;
|
||||
pub use parties::{MarketMaker, Player};
|
||||
|
||||
@@ -420,7 +420,7 @@ pub struct ContractSignatures {
|
||||
/// [`EventAnnouncement::outcome_messages`]. Each adaptor signature can be decrypted
|
||||
/// by the [`EventAnnouncement`]'s oracle producing an attestation signature using
|
||||
/// [`EventAnnouncement::attestation_secret`].
|
||||
pub outcome_tx_signatures: BTreeMap<usize, AdaptorSignature>,
|
||||
pub outcome_tx_signatures: BTreeMap<OutcomeIndex, AdaptorSignature>,
|
||||
/// A set of signatures needed for broadcasting split transactions. Each signature
|
||||
/// is specific to a certain combination of player and outcome.
|
||||
pub split_tx_signatures: BTreeMap<WinCondition, CompactSignature>,
|
||||
@@ -492,7 +492,10 @@ impl SignedContract {
|
||||
}
|
||||
|
||||
/// Return an unsigned outcome transaction.
|
||||
pub fn unsigned_outcome_tx<'a>(&'a self, outcome_index: usize) -> Option<&'a Transaction> {
|
||||
pub fn unsigned_outcome_tx<'a>(
|
||||
&'a self,
|
||||
outcome_index: OutcomeIndex,
|
||||
) -> Option<&'a Transaction> {
|
||||
self.dlc
|
||||
.outcome_tx_build
|
||||
.outcome_txs()
|
||||
@@ -503,7 +506,7 @@ impl SignedContract {
|
||||
/// to a specific outcome.
|
||||
pub fn signed_outcome_tx(
|
||||
&self,
|
||||
outcome_index: usize,
|
||||
outcome_index: OutcomeIndex,
|
||||
attestation: impl Into<MaybeScalar>,
|
||||
) -> Result<Transaction, Error> {
|
||||
let attestation = attestation.into();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use secp::{MaybePoint, MaybeScalar, Point, Scalar};
|
||||
|
||||
use crate::OutcomeIndex;
|
||||
|
||||
/// An oracle's announcement of a future event.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EventAnnouncement {
|
||||
@@ -18,7 +20,7 @@ pub struct EventAnnouncement {
|
||||
|
||||
impl EventAnnouncement {
|
||||
/// Computes the oracle's locking point for the given outcome index.
|
||||
pub fn attestation_lock_point(&self, index: usize) -> Option<MaybePoint> {
|
||||
pub fn attestation_lock_point(&self, index: OutcomeIndex) -> Option<MaybePoint> {
|
||||
let msg = &self.outcome_messages.get(index)?;
|
||||
|
||||
let e: MaybeScalar = musig2::compute_challenge_hash_tweak(
|
||||
|
||||
Reference in New Issue
Block a user