@@ -356,13 +356,15 @@ spent. In general, using CHECKTEMPLATEVERIFY with more than one input is difficu
356
356
and exposes subtle issues, so multiple inputs should not be used except in
357
357
specific applications.
358
358
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,
360
360
making this field strictly redundant. However, separately committing to this number makes it easier
361
361
to construct DefaultCheckTemplateVerifyHash from script.
362
362
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.
366
368
367
369
=====Committing to the Sequences Hash =====
368
370
@@ -378,12 +380,14 @@ script.
378
380
379
381
=====Committing to the Number of Outputs =====
380
382
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,
382
384
making this field strictly redundant. However, separately committing to this number makes it easier
383
385
to construct DefaultCheckTemplateVerifyHash from script.
384
386
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.
387
391
388
392
=====Committing to the outputs hash =====
389
393
0 commit comments