Skip to content

Commit 10891f6

Browse files
authored
Generalized contract_info TLV (#130)
* Updated TLVs to allow support for numeric outcome and multiple oracle DLCs * Added threshold field to multi-oracle oracle_infos * Responded to review * Some more review
1 parent 0481ff5 commit 10891f6

File tree

2 files changed

+123
-17
lines changed

2 files changed

+123
-17
lines changed

Messaging.md

Lines changed: 119 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ All data fields are unsigned big-endian unless otherwise specified.
1515
* [DLC Specific Types](#dlc-specific-types)
1616
* [The `contract_info` Type](#the-contract_info-type)
1717
* [Version 0 `contract_info`](#version-0-contract_info)
18+
* [The `contract_descriptor` Type](#the-contract_descriptor-type)
19+
* [Version 0 `contract_descriptor`](#version-0-contract_descriptor)
20+
* [Version 1 `contract_descriptor`](#version-1-contract_descriptor)
1821
* [The `oracle_info` Type](#the-oracle_info-type)
1922
* [Version 0 `oracle_info`](#version-0-oracle_info)
23+
* [Version 1 `oracle_info`](#version-1-oracle_info)
24+
* [Version 2 `oracle_info`](#version-2-oracle_info)
25+
* [The `oracle_params` Type](#the-oracle_params-type)
26+
* [Version 0 `oracle_params`](#version-0-oracle_params)
27+
* [The `negotiation_fields` Type](#the-negotiation_fields-type)
28+
* [Version 0 `negotiation_fields`](#version-0-negotiation_fields)
29+
* [Version 1 `negotiation_fields`](#version-1-negotiation_fields)
2030
* [The `funding_input` Type](#the-funding_input-type)
2131
* [Version 0 `funding_input`](#version-0-funding_input)
2232
* [The `cet_adaptor_signatures` Type](#the-cet_adaptor_signatures-type)
@@ -87,33 +97,130 @@ The following DLC-specific types are used throughout the specification. All type
8797

8898
### The `contract_info` Type
8999

90-
This type contains information about a contracts outcomes and their corresponding payouts. To save space, only one side's POV is included in this message as the other can be derived using `remote_payout = total_collateral - local_payout`.
100+
This type contains information about a contract's outcomes, their corresponding payouts, and the oracles to be used.
91101

92102
#### Version 0 `contract_info`
93103

94-
1. type: 42768 (`contract_info_v0`)
104+
1. type: 55342 (`contract_info_v0`)
95105
2. data:
96-
* [`bigsize`:`nb_outcomes`]
97-
* [`sha256`:`outcome_1`]
98-
* [`u64`:`outcome_1_local_payout`]
106+
* [`u64`:`total_collateral`]
107+
* [`contract_descriptor`:`contract_descriptor`]
108+
* [`oracle_info`:`oracle_info`]
109+
110+
`total_collateral` is the Satoshi-denominated value of the sum of all party's collateral.
111+
112+
### The `contract_descriptor` Type
113+
114+
This type contains information about a contract's outcomes and their corresponding payouts.
115+
116+
To save space, only the offerer's payouts are included in this message as the accepter's can be derived using
117+
`accept_payout = total_collateral - offer_payout`.
118+
119+
#### Version 0 `contract_descriptor`
120+
121+
1. type: 42768 (`contract_descriptor_v0`)
122+
2. data:
123+
* [`bigsize`:`num_outcomes`]
124+
* [`string`:`outcome_1`]
125+
* [`u64`:`payout_1`]
99126
* ...
100-
* [`sha256`:`outcome_n`]
101-
* [`u64`:`outcome_n_local_payout`]
127+
* [`string`:`outcome_num_outcomes`]
128+
* [`u64`:`payout_num_outcomes`]
129+
130+
This type represents an enumerated outcome contract.
102131

103-
This type of contract info is a simple enumeration of pairs of the hash of an outcome value with the corresponding payout for the local party.
132+
#### Version 1 `contract_descriptor`
133+
134+
1. type: 42784 (`contract_descriptor_v1`)
135+
2. data:
136+
* [`u16`:`num_digits`]
137+
* [`payout_function`:`payout_function`]
138+
* [`rounding_intervals`:`rounding_intervals`]
139+
140+
This type represents a numeric outcome contract.
141+
142+
The type `payout_function` is defined [here](PayoutCurve.md#curve-serialization).
143+
The type `rounding_intervals` is defined [here](NumericOutcome.md#rounding-interval-serialization).
104144

105145
### The `oracle_info` Type
106146

107-
This type contains information about the oracle(s) to be used in executing a DLC, and possibly the outcomes possible if these are not specified in the corresponding `contract_info`.
147+
This type contains information about the oracles to be used in executing a DLC.
108148

109149
#### Version 0 `oracle_info`
110150

111151
1. type: 42770 (`oracle_info_v0`)
112152
2. data:
113-
* [`x_point`:`oracle_public_key`]
114-
* [`x_point`:`oracle_nonce`]
153+
* [`oracle_announcement`:`oracle_announcement`]
154+
155+
This type of oracle info is for single-oracle events.
156+
157+
#### Version 1 `oracle_info`
158+
159+
1. type: 42786 (`oracle_info_v1`)
160+
2. data:
161+
* [`u16`:`threshold`]
162+
* [`u16`:`num_oracles`]
163+
* [`oracle_announcement`:`oracle_announcement_1`]
164+
* ...
165+
* [`oracle_announcment`:`oracle_announcement_num_oracles`]
166+
167+
This type of oracle info is for multi-oracle events where all oracles are signing messages chosen
168+
from a set of messages that exactly corresponds to the set of messages being signed by the other oracles,
169+
and any `threshold` oracles must sign (exactly) corresponding messages for execution to happen.
170+
171+
#### Version 2 `oracle_info`
172+
173+
1. type: 55340 (`oracle_info_v2`)
174+
2. data:
175+
* [`u16`:`threshold`]
176+
* [`u16`:`num_oracles`]
177+
* [`oracle_announcement`:`oracle_announcement_1`]
178+
* ...
179+
* [`oracle_announcment`:`oracle_announcement_num_oracles`]
180+
* [`oracle_params`:`oracle_params`]
181+
182+
The order of the oracle announcements represents a total ordering of preference on the oracles.
183+
184+
This type of oracle info is for multi-oracle numeric events where allowed differences in the values
185+
signed by oracles is specified in `oracle_params`.
186+
187+
### The `oracle_params` Type
188+
189+
Contains information about how oracle information is used in a given contract.
190+
191+
#### Version 0 `oracle_params`
192+
193+
1. type: 55338 (`oracle_params_v0`)
194+
2. data
195+
* [`u16`:`maxErrorExp`]
196+
* [`u16`:`minFailExp`]
197+
* [`bool`:`maximize_coverage`]
198+
199+
This type is used when the error bound requirements for any set of oracles `threshold` oracles in a
200+
multi-oracle numeric outcome DLC with allowed error is the same.
201+
202+
### The `negotiation_fields` Type
203+
204+
This type contains preferences of the accepter of a DLC which are taken into account during DLC construction.
205+
206+
#### Version 0 `negotiation_fields`
207+
208+
1. type: 55334 (`negotiation_fields_v0`)
209+
2. data:
210+
* (empty)
211+
212+
This type signifies that the accepter has no negotiation fields.
213+
214+
#### Version 1 `negotiation_fields`
215+
216+
1. type: 55336 (`negotiation_fields_v1`)
217+
2. data
218+
* [`rounding_intervals`: `rounding_intervals`]
219+
220+
`rounding_intervals` represents the maximum amount of allowed rounding at any possible oracle outcome
221+
in a numeric outcome DLC.
115222

116-
This type of oracle info is for single-oracle, single signature (and hence single nonce) events.
223+
The type `rounding_intervals` is defined [here](NumericOutcome.md#rounding-interval-serialization).
117224

118225
### The `funding_input` Type
119226

Protocol.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ the funding transaction and CETs.
6868
* [`byte`:`contract_flags`]
6969
* [`chain_hash`:`chain_hash`]
7070
* [`contract_info`:`contract_info`]
71-
* [`oracle_info`:`oracle_info`]
7271
* [`point`:`funding_pubkey`]
7372
* [`spk`:`payout_spk`]
7473
* [`u64`:`total_collateral_satoshis`]
@@ -87,8 +86,7 @@ The existence of the `chain_hash` allows nodes to open contracts
8786
across many distinct blockchains as well as have contracts within multiple
8887
blockchains opened to the same peer (if it supports the target chains).
8988

90-
`contract_info` specifies the sender's payouts for all events. `oracle_info`
91-
specifies the oracle(s) to be used as well as their commitments to events.
89+
`contract_info` specifies the contract to be constructed and the oracles to be used.
9290

9391
`funding_pubkey` is the public key in the 2-of-2 multisig script of
9492
the funding transaction output. `payout_spk` specifies the script
@@ -133,7 +131,7 @@ The receiving node MAY reject the contract if:
133131

134132
- it does not agree to the terms in `contract_info`.
135133
- the `contract_info` is missing relevant events.
136-
- it does not want to use the oracle(s) specified in `oracle_info`.
134+
- it does not want to use the oracle(s) specified in `contract_info`.
137135
- `total_collateral_satoshis` is too small.
138136
- `feerate_per_vb` is too small.
139137
- `feerate_per_vb` is too large.
@@ -142,7 +140,7 @@ The receiving node MUST reject the contract if:
142140

143141
- the `chain_hash` value is set to a hash of a chain that is unknown to the receiver.
144142
- the `contract_info` refers to events unknown to the receiver.
145-
- the `oracle_info` refers to an oracle unknown or inaccessible to the receiver.
143+
- the `contract_info` refers to an oracle unknown or inaccessible to the receiver.
146144
- it considers `feerate_per_vb` too small for timely processing or unreasonably large.
147145
- `funding_pubkey` is not a valid secp256k1 pubkey in compressed format.
148146
- `funding_inputs` do not contribute at least `total_collateral_satoshis` plus full [fee payment](Transactions.md#fee-payment).
@@ -165,6 +163,7 @@ and closing transactions.
165163
* [`spk`:`change_spk`]
166164
* [`cet_adaptor_signatures`:`cet_adaptor_signatures`]
167165
* [`signature`:`refund_signature`]
166+
* [`negotiation_fields`:`negotiation_fields`]
168167

169168
#### Requirements
170169

0 commit comments

Comments
 (0)