Skip to content

Commit e5a539c

Browse files
committed
Restrictions on Script Public Keys with standardness rules
1 parent 10891f6 commit e5a539c

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

Protocol.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [The `offer_dlc` Message](#the-offer_dlc-message)
99
* [The `accept_dlc` Message](#the-accept_dlc-message)
1010
* [The `sign_dlc` Message](#the-sign_dlc-message)
11+
* [Script Pubkey Standardness Definition](#script-pubkey-standardness-definition)
1112
* [Authors](#authors)
1213

1314
# Contract
@@ -110,6 +111,7 @@ The sending node MUST:
110111

111112
- set undefined bits in `contract_flags` to 0.
112113
- ensure the `chain_hash` value identifies the chain it wishes to open the contract within.
114+
- set `payout_spk` and `change_spk` to a [standard script pubkey](#script-pubkey-standardness-definition)
113115
- set `funding_pubkey` to a valid secp256k1 pubkey in compressed format.
114116
- set `total_collateral_satoshis` to a value greater than or equal to 1000.
115117
- set `contract_maturity_bound` and `contract_timeout` to either both be UNIX timestamps, or both be block heights as distinguished [here](https://en.bitcoin.it/wiki/NLockTime).
@@ -141,9 +143,11 @@ The receiving node MUST reject the contract if:
141143
- the `chain_hash` value is set to a hash of a chain that is unknown to the receiver.
142144
- the `contract_info` refers to events unknown to the receiver.
143145
- the `contract_info` refers to an oracle unknown or inaccessible to the receiver.
146+
- `payout_spk` or `change_spk` are not a [standard script pubkey](#script-pubkey-standardness-definition).
144147
- it considers `feerate_per_vb` too small for timely processing or unreasonably large.
145148
- `funding_pubkey` is not a valid secp256k1 pubkey in compressed format.
146149
- `funding_inputs` do not contribute at least `total_collateral_satoshis` plus full [fee payment](Transactions.md#fee-payment).
150+
- Any input in `funding_inputs` is not a [standard script pubkey](#script-pubkey-standardness-definition).
147151

148152
### The `accept_dlc` Message
149153

@@ -172,6 +176,7 @@ The `temporary_contract_id` MUST be the SHA256 hash of the `offer_dlc` message.
172176
The sender MUST:
173177

174178
- 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`.
179+
- set `payout_spk` and `change_spk` to a [standard script pubkey](#script-pubkey-standardness-definition)
175180
- set `cet_adaptor_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.
176181
- include an adaptor signature in `cet_adaptor_signatures` for every event specified in the `offer_dlc`'s `contract_info`.
177182
- 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).
@@ -185,10 +190,14 @@ The receiver:
185190

186191
- if `total_collateral_satoshis` is not large enough:
187192
- MAY reject the contract.
193+
- if `payout_spk` or `change_spk` are not a [standard script pubkey](#script-pubkey-standardness-definition)
194+
- MUST reject the contract.
188195
- if `cet_adaptor_signatures` or `refund_signature` fail validation:
189196
- MUST reject the contract.
190-
- if `funding_inputs` do not contribute at least `total_collateral_satoshis` plus [fee payment](Transactions.md#fee-payment)
191-
- MUST reject the contract.
197+
- if `funding_inputs` do not contribute at least `total_collateral_satoshis` plus [fee payment](Transactions.md#fee-payment)
198+
- MUST reject the contract.
199+
- if Any input in `funding_inputs` is not a [standard script pubkey](#script-pubkey-standardness-definition).
200+
- MUST reject the contract.
192201

193202
Other fields have the same requirements as their counterparts in `offer_dlc`.
194203

@@ -227,12 +236,27 @@ The recipient:
227236
- on receipt of a valid `sign_dlc`:
228237
- SHOULD broadcast the funding transaction.
229238

239+
### Script Pubkey Standardness Definition
240+
241+
For a script pub key to be valid it must be in one of the following forms:
242+
243+
1. `OP_DUP` `OP_HASH160` `20` 20-bytes `OP_EQUALVERIFY` `OP_CHECKSIG` (pay to pubkey hash), OR
244+
2. `OP_HASH160` `20` 20-bytes `OP_EQUAL` (pay to script hash), OR
245+
3. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey hash), OR
246+
4. `OP_0` `32` 32-bytes (version 0 pay to witness script hash), OR
247+
5. `OP_1` through `OP_16` inclusive, followed by a single push of 2 to 40 bytes
248+
(witness program versions 1 through 16)
249+
250+
These script pub key forms include only standard forms accepted by the wider set of deployed Bitcoin clients in the network, which increase the chances of successful propagation to miners.
251+
230252
# Authors
231253

232254
Nadav Kohen <[email protected]>
233255

256+
Ben Carman <[email protected]>
257+
234258
[ FIXME: Add Authors ]
235259

236260
![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png "License CC-BY")
237261
<br>
238-
This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).
262+
This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).

0 commit comments

Comments
 (0)