Skip to content

Commit cf7e49e

Browse files
committed
Responded to review
1 parent e64b6e8 commit cf7e49e

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

Messaging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ All data fields are unsigned big-endian unless otherwise specified.
1212
* [Connection Handling and Multiplexing](#connection-handling-and-multiplexing)
1313
* [Message Format](#message-format)
1414
* [Fundamental Types](#fundamental-types)
15-
* [Authors](#authors)
15+
* [Authors](#authors)
1616

1717
## Connection Handling and Multiplexing
1818

@@ -45,8 +45,8 @@ The following convenience types are also defined:
4545
* `sha256`: a 32-byte SHA2-256 hash
4646
* `signature`: a 64-byte bitcoin Elliptic Curve signature
4747
* `point`: a 33-byte Elliptic Curve point (compressed encoding as per [SEC 1 standard](http://www.secg.org/sec1-v2.pdf#subsubsection.2.3.3))
48-
* `spk`: A bitcoin script public key encoded as ASM prefixed with a CompactSize
49-
* `short_contract_id`: an 8 byte value identifying a contract (see [BOLT #7](07-routing-gossip.md#definition-of-short-channel-id))
48+
* `spk`: A bitcoin script public key encoded as ASM prefixed with a Bitcoin CompactSize unsigned integer
49+
* `short_contract_id`: an 8 byte value identifying a contract funding transaction on-chain (see [BOLT #7](07-routing-gossip.md#definition-of-short-channel-id))
5050
* `bigsize`: a variable-length, unsigned integer similar to Bitcoin's CompactSize encoding, but big-endian. Described in [BigSize](01-messaging.md#appendix-a-bigsize-test-vectors).
5151
* `contract_info`: ???
5252
* `oracle_info`: ???

Protocol.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@
1414

1515
## Definition of `contract_id`
1616

17-
Most messages use a `contract_id` to identify the contract. It's
18-
derived from the funding transaction by combining the `funding_txid`
19-
and the `funding_output_index`, using big-endian exclusive-OR
20-
(i.e. `funding_output_index` alters the last 2 bytes).
21-
2217
Prior to a contract being accepted, a `temporary_contract_id` is used,
2318
which is the SHA256 hash of the offer message.
2419

20+
Most messages use a `contract_id` to identify the contract. It's
21+
derived from the funding transaction and the offer by combining the `funding_txid`
22+
and the `funding_output_index` and the `temporary_contract_id`, using big-endian
23+
exclusive-OR (i.e. `funding_output_index` alters the last 2 bytes of
24+
`funding_txid XOR temporary_contract_id`).
25+
2526
## Contract Negotiation
2627

2728
Contract Negotiation consists of the initiator (aka offerer) sending an `offer_dlc` message,
2829
followed by the responding node (aka accepter) sending `accept_dlc`. With the
2930
contract parameters locked in, both parties are able to create the funding
3031
transaction and subsequently all contract execution transactions (CETs) and the refund transaction, as described in the [transaction specification](Transactions.md). As such, the accepter includes its signatures of the CETs and refund transaction in the `accept_dlc` message.
31-
The initiator now able to generate signatures for all CETs and the refund transaction, as well as the funding transaction, and send it over using the `sign_dlc` message.
32+
The initiator is now able to generate signatures for all CETs and the refund transaction, as well as the funding transaction, and send them over using the `sign_dlc` message.
3233

3334
Once the accepter receives the `sign_dlc` message, it
3435
must broadcast the funding transaction to the Bitcoin network.
@@ -59,7 +60,7 @@ funding transaction).
5960
### The `offer_dlc` Message
6061

6162
This message contains information about a node and indicates its
62-
desire to open a new contract. This is the first step toward creating
63+
desire to enter into a new contract. This is the first step toward creating
6364
the funding transaction and CETs.
6465

6566
1. type: ??? (`offer_dlc`)
@@ -74,9 +75,9 @@ the funding transaction and CETs.
7475
* [`u16`:`num_funding_inputs`]
7576
* [`num_funding_inputs*funding_input`:`funding_inputs`]
7677
* [`spk`:`change_spk`]
77-
* [`u64`:`feerate_per_vb`]
78-
* [`u32`:`contract_maturity_cltv`]
79-
* [`u32`:`contract_timeout_cltv`]
78+
* [`u64`:`feerate_per_kw`]
79+
* [`u32`:`contract_maturity_bound`]
80+
* [`u32`:`contract_timeout`]
8081

8182
No bits of `contract_flags` are currently defined, this field should be ignored.
8283

@@ -99,11 +100,11 @@ the sender and `funding_inputs` contains outputs, outpoints, and expected weight
99100
of the sender's funding inputs. `change_spk` specifies the script pubkey that funding
100101
change should be sent to.
101102

102-
`feerate_per_vb` indicates the fee rate in satoshi per virtual byte that both
103+
`feerate_per_kw` indicates the fee rate in satoshi per 1000-weight that both
103104
sides will use to compute fees in the funding transaction, as described in the
104105
[transaction specification](Transactions.md).
105106

106-
`contract_maturity_cltv` is the CLTV timelock to be put on CETs. `contract_timeout_cltv` is the CLTV timelock to be put on the refund transaction.
107+
`contract_maturity_bound` is the nLockTime to be put on CETs. `contract_timeout` is the nLockTime to be put on the refund transaction.
107108

108109
#### Requirements
109110

@@ -112,15 +113,15 @@ The sending node MUST:
112113
- set undefined bits in `contract_flags` to 0.
113114
- ensure the `chain_hash` value identifies the chain it wishes to open the contract within.
114115
- set `funding_pubkey` to a valid secp256k1 pubkey in compressed format.
115-
- set `total_collateral_satoshis` greater than or equal to 1000.
116-
- set `contract_maturity_cltv` and `contract_timeout_cltv` to either both be UNIX timestamps, or both be block heights as distinguished in [BIP 65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki).
117-
- set `contract_maturity_cltv` to be less than `contract_timeout_cltv`.
116+
- set `total_collateral_satoshis` to a value greater than or equal to 1000.
117+
- set `contract_maturity_bound` and `contract_timeout` to either both be UNIX timestamps, or both be block heights as distinguished in [BIP 65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki).
118+
- set `contract_maturity_bound` to be less than `contract_timeout`.
118119

119120
The sending node SHOULD:
120121

121-
- set `feerate_per_vb` to at least the rate it estimates would cause the transaction to be immediately included in a block.
122-
- set `contract_maturity_cltv` to the earliest expected oracle signature time.
123-
- set `contract_timeout_cltv` sufficiently long after `contract_maturity_cltv` to allow for late oracle signatures and other delays to closing the contract.
122+
- set `feerate_per_kw` to at least the rate it estimates would cause the transaction to be immediately included in a block.
123+
- set `contract_maturity_bound` to the earliest expected oracle signature time.
124+
- set `contract_timeout` sufficiently long after `contract_maturity_bound` to allow for late oracle signatures and other delays to closing the contract.
124125

125126
The receiving node MUST:
126127

@@ -138,9 +139,9 @@ The receiving node MUST reject the contract if:
138139
- the `chain_hash` value is set to a hash of a chain that is unknown to the receiver.
139140
- the `contract_info` refers to events unknown to the receiver.
140141
- the `oracle_info` refers to an oracle unknown to the receiver.
141-
- it considers `feerate_per_vb` too small for timely processing or unreasonably large.
142+
- it considers `feerate_per_kw` too small for timely processing or unreasonably large.
142143
- `funding_pubkey` is not a valid secp256k1 pubkey in compressed format.
143-
- the funder's amount for the funding transaction is not sufficient for full [fee payment](Transactions.md#fee-payment).
144+
- the funder's amount for the funding transaction is not sufficient for their full [fee payment](Transactions.md#fee-payment).
144145

145146
### The `accept_dlc` Message
146147

@@ -170,6 +171,7 @@ The sender MUST:
170171
- set `total_collateral_satoshis` sufficiently large so that the sum of both parties' total collaterals is at least as large as the largest payout in the `offer_dlc`'s `contract_info`.
171172
- set `cet_signatures` to valid adaptor signatures, using its `funding_pubkey` for each CET, as defined in the [transaction specification](Transactions.md#contract-execution-transaction) and using signature public keys computed using the `offer_dlc`'s `contract_info` and `oracle_info` as adaptor points.
172173
- include an adaptor signature in `cet_signatures` for every event specified in the `offer_dlc`'s `contract_info`.
174+
- set `refund_signature` to the valid signature, using its `funding_pubkey` for the refund transaction, as defined in the [transaction specification](Transactions.md#refund-transaction).
173175

174176
The receiver:
175177

@@ -182,11 +184,11 @@ Other fields have the same requirements as their counterparts in `offer_dlc`.
182184

183185
### The `sign_dlc` Message
184186

185-
This message gives all of the initiator's the signatures, which allows the receiver
187+
This message gives all of the initiator's signatures, which allows the receiver
186188
to broadcast the funding transaction with both parties being fully committed to
187189
all closing transactions.
188190

189-
This message introduces the `contract_id` to identify the contract. It's derived from the funding transaction by combining the `funding_txid` and the `funding_output_index`, using big-endian exclusive-OR (i.e. `funding_output_index` alters the last 2 bytes).
191+
This message introduces the [`contract_id`](#definition-of-contract_id) to identify the contract.
190192

191193
1. type: ??? (`sign_dlc`)
192194
2. data:
@@ -199,7 +201,7 @@ This message introduces the `contract_id` to identify the contract. It's derived
199201

200202
The sender MUST:
201203

202-
- set `channel_id` by exclusive-OR of the `funding_txid` and the `funding_output_index` from the `offer_dlc` and `accept_dlc` messages.
204+
- set `contract_id` by exclusive-OR of the `funding_txid` and the `funding_output_index` from the `offer_dlc` and `accept_dlc` messages.
203205
- set `cet_signatures` to valid adaptor signatures, using its `funding_pubkey` for each CET, as defined in the [transaction specification](Transactions.md#contract-execution-transaction) and using signature public keys computed using the `offer_dlc`'s `contract_info` and `oracle_info` as adaptor points.
204206
- include an adaptor signature in `cet_signatures` for every event specified in the `offer_dlc`'s `contract_info`.
205207
- set `refund_signature` to the valid signature, using its `funding_pubkey` for the refund transaction, as defined in the [transaction specification](Transactions.md#refund-transaction).

0 commit comments

Comments
 (0)