Skip to content

Commit 6058f2f

Browse files
committed
[BIP-119] Whitspace Consistency
1 parent b305d56 commit 6058f2f

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

bip-0119.mediawiki

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ for purposes of confirmation using CHECKTEMPLATEVERIFY. Then, some time later, t
5757
be expanded out of that UTXO when the demand for blockspace is decreased. These payments can be
5858
structured in a tree-like fashion to reduce individual costs of redemption.
5959

60-
6160
The below chart showcases the structure of these transactions in comparison to
6261
normal transactions and batched transactions.
6362

@@ -71,6 +70,7 @@ is provided in this BIP's subdirectory.
7170
<img src="bip-0119/fifty.png" align="middle"></img>
7271

7372
===Payment Channels===
73+
7474
There are numerous payment channel related uses.
7575

7676
====Channel Factories====
@@ -84,6 +84,7 @@ penultimate transaction node.
8484
Thus, coins sent using a congestion controlled transaction can still enjoy instant liquidity.
8585

8686
====Non-Interactive Channels====
87+
8788
When opening a traditional payment channel, both parties to the channel must participate. This is
8889
because the channel uses pre-signed multi-sig transactions to ensure that a channel can always be
8990
exited by either party, before entering.
@@ -94,6 +95,7 @@ for their private key to be online.
9495
<img src="bip-0119/nic.svg" align="middle"></img>
9596

9697
====Increased Channel Routes====
98+
9799
In the Lightning Network protocol, Hashed Time Locked Contracts (HTLCS) are used in the construction
98100
of channels. A new HTLC is required per route that the channel is serving in.
99101
In BOLT #2, this maximum number of HTLCs in a channel is hard limited to 483 as the maximum safe
@@ -107,7 +109,6 @@ HTLCS.
107109
Because each HTLC can have its own relative time lock in the tree, this also improves the latency
108110
sensitivity of the lightning protocol on contested channel close.
109111

110-
111112
===Wallet Vaults===
112113

113114
When greater security is required for cold storage solutions, there can be
@@ -133,6 +134,7 @@ before. Further Each participant doesn't need to know the totality of the outpu
133134
that output, they only have to verify their own sub-tree will pay them.
134135

135136
==Detailed Specification==
137+
136138
The below code is the main logic for verifying CHECKTEMPLATEVERIFY, and is the canonical
137139
specification for the semantics of OP_CHECKTEMPLATEVERIFY.
138140

@@ -203,7 +205,6 @@ The hash is computed as follows:
203205
return h.GetSHA256();
204206
}
205207
206-
207208
A PayToBareDefaultCheckTemplateVerifyHash output matches the following template:
208209

209210
bool CScript::IsPayToBareDefaultCheckTemplateVerifyHash() const
@@ -223,7 +224,7 @@ NEVER_ACTIVE/NO_TIMEOUT, but this is subject to change while the BIP is a draft.
223224

224225
For the avoidance of unclarity, the parameters to be determined are:
225226

226-
// Deployment of CTV (BIP 119)
227+
// Deployment of CTV (BIP 119)
227228
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY].bit = 5;
228229
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
229230
consensus.vDeployments[Consensus::DEPLOYMENT_CHECKTEMPLATEVERIFY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
@@ -234,7 +235,6 @@ SCRIPT_VERIFY_DEFAULT_CHECK_TEMPLATE_VERIFY_HASH flag is set, the network should
234235
execute a NOP4 as SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS for policy and a NOP for
235236
consensus.
236237

237-
238238
In order to facilitate using CHECKTEMPLATEVERIFY, the common case of a
239239
PayToBareDefaultCheckTemplateVerifyHash
240240
with no scriptSig data shall be made standard to permit relaying. Future template types may be
@@ -245,26 +245,20 @@ standardized later as policy changes.
245245
A reference implementation and tests are available here:
246246
https://github.com/JeremyRubin/bitcoin/tree/checktemplateverify.
247247

248-
249248
==Rationale==
250249

251250
The goal of CHECKTEMPLATEVERIFY is to be minimal impact on the existing codebase -- in the
252251
future, as we become aware of more complex but shown to be safe use cases new template types can be added.
253252

254-
255253
Below we'll discuss the rules one-by-one:
256254

257-
258-
259255
====The DefaultCheckTemplateVerifyHash of the transaction at the current input index matches the top of the stack====
260256

261257
The set of data committed to is a superset of data which can impact the TXID of the transaction,
262258
other than the inputs. This ensures that for a given known input, the TXIDs can also be known ahead
263259
of time. Otherwise, CHECKTEMPLATEVERIFY would not be usable for Channel Factory type constructions
264260
as the redemption TXID could be malleated and pre-signed transactions invalidated.
265261

266-
267-
268262
=====Committing to the version and locktime=====
269263

270264
Were these values not committed, it would be possible to delay the spending of
@@ -296,7 +290,6 @@ precomputed for each transaction to optimize SIGHASH_ALL signatures.
296290
Committing to the hash additionally makes it simpler to construct DefaultCheckTemplateVerifyHash safely and unambiguously from
297291
script.
298292

299-
300293
=====Committing to the number of inputs=====
301294

302295
If we allow more than one input to be spent in the transaction then it would be
@@ -459,7 +452,6 @@ does not make sense for input index to be the last field. However, given the des
459452
able to express a "don't care" index easily (e.g., for decentralized kickstarter-type transactions),
460453
this value is placed last.
461454

462-
463455
===Design Tradeoffs and Risks===
464456
Covenants have historically been controversial given their potential for fungibility risks -- coins
465457
could be minted which have a permanent restriction on how they may or may not be spent or required
@@ -474,17 +466,18 @@ transactions which create all the inputs directly in this regard.
474466
Furthermore, templates are restricted to be spendable as a known number of inputs only, preventing
475467
unintentional introduction of the 'half spend' problem.
476468

477-
478469
Templates, as restricted as they are, bear some risks.
479470

480471
====Permanently Unspendable Outputs====
472+
481473
The preimage argument passed to CHECKTEMPLATEVERIFY may be unknown or otherwise unsatisfiable.
482474
However, requiring knowledge that an address is spendable from is incompatible with sender's ability
483475
to spend to any address (especially, OP_RETURN). If a sender needs to know the template can be spent
484476
from before sending, they may request a signature of an provably non-transaction challenge string
485477
from the leafs of the CHECKTEMPLATEVERIFY tree.
486478

487479
====Forwarding Addresses====
480+
488481
Key-reuse with CHECKTEMPLATEVERIFY may be used as a form of "forwarding address contract".
489482
A forwarding address is an address which can automatically execute in a predefined way.
490483
For example, a exchange's hot wallet might use an address which can automatically be moved to a cold
@@ -510,7 +503,6 @@ reuse-unsafe.
510503
Because CHECKTEMPLATEVERIFY commits to the input index currently being spent, reused-keys are
511504
guaranteed to execute in separate transactions which reduces the risk of "half-spend" type issues.
512505

513-
514506
====NOP-Default and Standardness Rules====
515507

516508
If the argument length is not exactly 32, CHECKTEMPLATEVERIFY treats it as a NOP.
@@ -523,8 +515,8 @@ stricter standardness rules to be enforced during consensus. Should that develop
523515
transaction directly to the network relying on standardness rejection, an standardness-invalid but
524516
consensus-valid transaction may be caused, leading to a potential loss of funds.
525517

526-
527518
====Feature Redundancy====
519+
528520
CHECKTEMPLATEVERIFY templates are substantially less risky than other covenant systems. If
529521
implemented, other covenant systems could make the CHECKTEMPLATEVERIFY's functionality redundant.
530522
However, given CHECKTEMPLATEVERIFY's simple semantics and low on chain cost it's likely that it
@@ -538,7 +530,6 @@ unintended behavior.
538530
Alternatively, SIGHASH_ANYPREVOUTANYSCRIPT based covenant designs can implement
539531
something similar to templates, via a scriptPubKey like:
540532

541-
542533
<sig of desired TX with PK and fixed nonce R || SIGHASH_ANYPREVOUTANYSCRIPT <PK with public SK> OP_CHECKSIG
543534
544535
SIGHASH_ANYPREVOUTANYSCRIPT bears additional technical and implementation risks
@@ -564,7 +555,6 @@ than CHECKTEMPLATEVERIFY, and encumbers additional verification overhead absent
564555
from CHECKTEMPLATEVERIFY. These types of covenants also bear similar potential
565556
recursion issues to OP_COV which make it unlikely for inclusion in Bitcoin.
566557

567-
568558
Given the simplicity of this approach to implement and analyze, and the benefits realizable by user
569559
applications, CHECKTEMPLATEVERIFY's template based approach is proposed in lieu of more complete
570560
covenants system.
@@ -575,6 +565,7 @@ This section describes updates to OP_CHECKTEMPLATEVERIFY that are possible in
575565
the future as well as synergies with other possible upgrades.
576566

577567
=====CHECKTEMPLATEVERIFY Versions=====
568+
578569
OP_CHECKTEMPLATEVERIFY currently only verifies properties of 32 byte arguments.
579570
In the future, meaning could be ascribed to other length arguments. For
580571
example, a 33-byte argument could just the last byte as a control program. In
@@ -623,6 +614,7 @@ concatenates it to the template and checks the template matches the transaction.
623614
OP_SIZE 4 OP_EQUALVERIF
624615
<nVersion || nLockTime || input count || sequences hash || output count || outputs hash>
625616
OP_SWAP OP_CAT OP_SHA256 OP_CHECKTEMPLATEVERIFY
617+
626618
== Backwards Compatibility ==
627619

628620
OP_CHECKTEMPLATEVERIFY replaces a OP_NOP4 with stricter verification semantics. Therefore, scripts
@@ -638,13 +630,11 @@ Older wallet software will be able to accept spends from OP_CHECKTEMPLATEVERIFY
638630
require an upgrade in order to treat PayToBareDefaultCheckTemplateVerifyHash chains with a confirmed ancestor as
639631
being "trusted" (i.e., eligible for spending before the transaction is confirmed).
640632

641-
642-
643633
Backports of OP_CHECKTEMPLATEVERIFY can be trivially prepared (see the reference implementation)
644634
for older node versions that can be patched but not upgraded to a newer major release.
645635

646-
647636
== References ==
637+
648638
*[https://utxos.org utxos.org informational site]
649639
*[https://www.youtube.com/watch?v=YxsjdIl0034&t=2451 Scaling Bitcoin Presentation]
650640
*[https://bitcoinops.org/en/newsletters/2019/05/29/ Optech Newsletter Covering OP_CHECKOUTPUTSHASHVERIFY]
@@ -656,6 +646,7 @@ for older node versions that can be patched but not upgraded to a newer major re
656646
657647

658648
===Note on Similar Alternatives===
649+
659650
An earlier version of CHECKTEMPLATEVERIFY, CHECKOUTPUTSHASHVERIFY, is withdrawn
660651
in favor of CHECKTEMPLATEVERIFY. CHECKOUTPUTSHASHVERIFY did not commit to the
661652
version or lock time and was thus insecure.
@@ -668,4 +659,5 @@ CHECKTEMPLATEVERIFY has also been previously referred to as OP_SECURETHEBAG, whi
668659
to aid in searching and referencing discussion on this BIP.
669660

670661
==Copyright==
662+
671663
This document is licensed under the 3-clause BSD license.

0 commit comments

Comments
 (0)