tradecraftio / tradecraft

Tradecraft integration/staging tree https://tradecraft.io/download
Other
13 stars 9 forks source link

Witness program format extensions #62

Closed maaku closed 4 years ago

maaku commented 4 years ago

This PR expands the definition of what is a segwit output (the IsWitnessProgram API) in three ways:

  1. The range of allowed outer witness versions (the first opcode of a witness program) is expanded from 17 to 31 different values. To the previous values of OP_0 through OP_16 we add 1NEGATE, NOP, DEPTH, CODESEPARATOR, and NOP1 through NOP10 (including CLTV, CSV, and MBV). This is the full range of single-byte opcodes that may begin a script, giving us a total of 31 different outer-version values for future hash mechanism extensions.

  2. An optional shard specifier is allowed after the witness program, with 256 different unique values. The first 16 shards have a single-byte opcode format (OP_1 through OP_16), as does the 128th shard (1NEGATE, as it would otherwise be negative zero), and the other shards specifiers are one-byte pushes.

  3. An optional "extension output" push between 2- and 75-bytes in length after the shard specifier, or after the witness program if the shard specifier is not present. This is an unconstrained field for use by future extensions to place extra information in the output needed for things like confidential transactions or issued assets, or a commitments to these values.