Bitcoin Covenants: TXHASH And CHECKTXHASHVERIFY(BIP 346)

This is the third article in A series Deep dives in individual alliance proposals that have reached a high school point by deserving a thorough break.

TXHASH and Checktxhashverify (TXHASH), advanced by Steven Roose and Brandon Black with a bip number currently not assigned, is a “models -based” alliance that can conceptually see as an extension or a more advanced version of CheckTemplavely (CTV).

Before entering the sharpness of how TXHASH works, we update on the data in a bitcoin transaction.

At high level you have the exits, the inputs and the witness (or sig of scripts for non -sequel transactions in the input).

Global transaction fields:

  • Version
  • Marker, which indicates Segwit with a Flag value
  • Flag, which indicates Segwit with a Flag value
  • Input count
  • Counting of exits
  • Nlocktime, used for Timellocks

Each input contains:

  • TXID of the previous transaction
  • Vout (index) of the output from that transaction shopping
  • Scriptsig size
  • Scriptsig (if a non segwit transaction)
  • Sequence number (used for RBF flaaging and Timelock relative).

Each output contains:

  • Amount of Satoshis assigned to the output
  • Scriptpubkeysize, the size of the blocking script
  • Scriptpubkey, the actual lock script

We can ignore the field of witnesses when considering TXHASH or controlletxhashverifice as neither of the two brochures limits the field of witnesses to preserve certain properties.

How txhash works

Both TXHASH (TAPSCRIPT only) and Checktxhashverify (Legacy and Tapscript script) have different behaviors on the stack due to the differences between Legacy and Tapscript scripts. For the purpose of this article, these differences are not material, so we will simply ignore them.

If CTV is an operating code of the alliance that limits a bitcoin output to be spent only in a singular and exactly defined way, TXHASH is an supercharged version of CTV that allows you to choose exactly which pieces of transaction are bound and must be spent exactly predefined and which pieces of transaction can be anything you want to spend time.

It gives you the best of both worlds, requesting something when you spend a limited coin of the alliance, but therefore it allows a user to do everything he wants with the rest of the funds available to them or the transaction they are creating.

This is achieved using the “TXFieldselettor”.

CTV simply uses a single hash of the default transaction to check at the time. With TXHASH, you need a way to communicate what information that hash is committed and what information is not. This is the work of the TXFieldselettor.

Txfieldselettor is essentially a series of bytes (which can be variable in length), with each bit that communicates to which fields in a transaction are engaged by the hash that will be verified. This allows you to select Specific Fields of the Transaction, Nlocktime, Version etc. It allows you to select specific fields of the inputs and outputs, i.e. or not to include the sequence number or the previous output ID or the TAPROOT attachment (a specific field for data on the TAPROOT scripts). The outputs, if they engage in scriptpubkey, the values ​​of the amounts, both or neither of them. You can also decide exactly which outputs and inputs these restrictions apply.

There is a certain complexity and flexibility in the way in which the TXFieldselettor is put together and you can read all the finest details here in the bent proposed if you are interested in those, but the main point to be removed is that it allows you to choose Exactly What parts of the transaction are limited by the alliance when someone goes to spend the burned production and which parts are not, to a very granular extent.

What is useful for TXHASH

First, TXHASH allows you to do everything possible with CTV. Therefore, all the value provided by CTV to optimize the coordination costs of everything that is currently possible with pre-operated transactions is also provided by TXHASH. But the massive capacity supercasts. Instead of having to engage for the entire transaction, you can only engage in the parts you care about.

This has two great benefits in theory immediately. First of all, in the management of taxes for the band for two layers it becomes easier to deal with. Currently it is necessary to use anchor output for regulation transactions with the level of taxes with the parent, in which a transaction that spends an output from an unconfirmed can add to the net commissions for both. TXHASH allows you to engage only in the output of the counterparties in a multi -party transaction and leave your free to do what you want (warning here that other things must be done to make it safe so that a third party cannot burn all your funds to the commissions), including the decrease slightly for RBF the transaction.

Secondly, the door is now open for multi-party protocols to allow granular guarantees on which off-chain transactions are committed to. Some users can now receive a guarantee on how their coins will be spent, but they don’t have to worry about what another group of users does with theirs. I can be sure that a TXFieldselettor guarantees that my coins are managed correctly and I don’t care about where someone else’s coins go.

In combination with Checksigfromstack (CSFS), TXHASH can facilitate a completely generalized suspense system. Sighash’s flag is part of a signature that communicates on which parts of the transaction control the signature. They are currently:

  • SIGHASH_All – Sign the entrances and outings
  • SIGHASH_NONE – Signature all inputs and without outputs
  • SIGHASH_SINGLE – SIGNS ALL INPUT AND OUTPUT with the same index of this input

None of these Sighash flag allows you to add new inputs to a transaction without invalidating them, but everyone has an Anyonecanpay version that signs only their own inputs and appropriate outings, allowing anyone to add new inputs and new outputs for the Anyonecans version of Sighash_none and Sighash_sinx.

Being able to “divert” new txfieldselectors that use CSF, users can emulate a suspended system that allows them to choose exactly which individual pieces of a transaction are committed or not.

TXHASH also allows you to enforce the equality between the input and output value by using individual TXFHIELDS fields that only engage in a single value field of an input or output that you want to inspect and therefore ensure that their hash are the same on the stack.

Closing thoughts

TXHASH is a potential supercharging of CTV, allowing an incredibly granular degree of introspection of the spending transaction that can be incredibly powerful, especially in combination with something like CSF.

However, that power is quite expressive to open the door to an incredibly large design space. One that could potentially have a material effect on Bitcoin’s overall incentives. Things how to guarantee equality of the quantity between outputs or inputs are very close to the territory of what is necessary for automated exchange without confidence in the chain. This is a serious source of removable value with miner (MEV), which was a very serious incentive and centralization problem for other blockchains to face.

TxHash should not be absolutely fired, as it provides incredibly powerful primitives for protocol developers to be exploited, but the potential implications of the second order of what people will build should be evaluated against positive.

Leave a Comment