Skip to content

Commit f59f235

Browse files
authored
Merge pull request bitcoin#1268 from JeremyRubin/patch-1
Fix BIP-119 Typo + Clarify the reasons for 32 bit lengths
2 parents 01fe8b4 + b96b171 commit f59f235

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

bip-0119.mediawiki

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,15 @@ spent. In general, using CHECKTEMPLATEVERIFY with more than one input is difficu
356356
and exposes subtle issues, so multiple inputs should not be used except in
357357
specific applications.
358358

359-
In principal, committing to the Sequences Hash (below) implicitly commits to the number of inputs,
359+
In principle, committing to the Sequences Hash (below) implicitly commits to the number of inputs,
360360
making this field strictly redundant. However, separately committing to this number makes it easier
361361
to construct DefaultCheckTemplateVerifyHash from script.
362362

363-
We treat the number of inputs as a `uint32_t` because signature checking code expects nIn to be an
364-
`unsigned int`, even though in principal a transaction can encode more than a `uint32_t`'s worth of
365-
inputs.
363+
We treat the number of inputs as a `uint32_t` because Bitcoin's consensus decoding logic limits vectors
364+
to `MAX_SIZE=33554432` and that is larger than `uint16_t` and smaller than `uint32_t`. 32 bits is also
365+
friendly for manipulation using Bitcoin's current math opcodes, should `OP_CAT` be added. Note that
366+
the max inputs in a block is further restricted by the block size to around 25,000, which would fit
367+
into a `uint16_t`, but that is an uneccessary abstraction leak.
366368

367369
=====Committing to the Sequences Hash=====
368370

@@ -378,12 +380,14 @@ script.
378380

379381
=====Committing to the Number of Outputs=====
380382

381-
In principal, committing to the Outputs Hash (below) implicitly commits to the number of outputs,
383+
In principle, committing to the Outputs Hash (below) implicitly commits to the number of outputs,
382384
making this field strictly redundant. However, separately committing to this number makes it easier
383385
to construct DefaultCheckTemplateVerifyHash from script.
384386

385-
We treat the number of outputs as a `uint32_t` because a `COutpoint` index is a `uint32_t`, even
386-
though in principal a transaction could encode more outputs.
387+
We treat the number of outputs as a `uint32_t` because a `COutpoint` index is a `uint32_t`.
388+
Further, Bitcoin's consensus decoding logic limits vectors to `MAX_SIZE=33554432` and that is
389+
larger than `uint16_t` and smaller than `uint32_t`. 32 bits is also friendly for manipulation using
390+
Bitcoin's current math opcodes, should `OP_CAT` be added.
387391

388392
=====Committing to the outputs hash=====
389393

0 commit comments

Comments
 (0)