Motivation
Bitcoin transactions can contain multiple inputs and outputs. Where inputs point to the outputs of the prior transactions. The current block validation process has to verify every input is not spent. As far as I know if one of the following is true it is considered that the input is not spent.
- When the referred the transaction + output index is a confirmed transaction and it’s not spent. To verify that, We have a database of unspent coins. And it’ll get updated once a block is connected or disconnected.
- When the referred transaction + output index is in the mempool and it’s considered as unspent. To verify this, The block creation process should verify the spent inputs that refer to txs in the mempool is only spent once. (I’m not sure if this is the only condition it should verify).
The motivation for virtual transactions is to eliminate the need to verify the second possibility.
Concept
The goal of virtual transactions are to maintain the function of spending unconfirmed transactions while removing the need for the validation of inputs that refer to a tx in the same block (stored in the mempool).
Two things are needed to achieve this goal.
- A new transaction type (lets call it TXV), It is an array of virtual transactions (lets call that VTX).
- A new local validator. The validator executes all unlocking scripts of the inputs to verify the validity of multiple chained transactions, And it verifies the balance of VTXs that have references to outputs of another VTX.
Each VTX is aware of all of its prior VTXs and the inputs of it can refer to output of them (VTXs that has came prior to it).
TXV needs to remain compatible with the rest of the current codebase. To achieve that it will be morphed to a regular transaction by concatenating all inputs and outputs except for the spent outputs and inputs that have a pointer to a VTX.
A VTX don’t have a global id until it’s included in a block.
If I’m not mistaken, The morphed tx will keep the balance of the transaction. But all unlocking scripts are no longer valid. Which I believe it’s not a major issue.
And every output can be spent once it’s included in a block and a txid is assigned to it.
The txid will remain to be the hash of the TXV, However since these types of transaction are designed to be replaceable, The txhash can change until it’s included in a block.
I’m aware a lot of work is needed to maintain compatibility, building tx formats, parsers, compilers & maybe a new types of data when it comes to communications between the nodes. etc etc.
It don’t consider this as an important feature to be added at this point in time. However, I believe this addition will enable parallel validation of txs until a block creation. Which is a huge upgrade compared to the current mempool implementation.