bitcoin-dev

Compressed Bitcoin Transactions

Compressed Bitcoin Transactions

Original Postby Tom Briar

Posted on: January 5, 2024 15:06 UTC

The recent Bitcoin Core updates have introduced a new Compressed Transaction Schema designed to minimize transaction sizes through various methods.

This schema primarily works by omitting recoverable data and using alternative representations, such as block height and index instead of the prevout for each input.

This compression technique is particularly beneficial in environments with low bandwidth but high CPU availability for decompression, like steganography or satellite/radio broadcasts. It also allows users to tailor transactions for better compression rates. Notably, the compression of Txid/Vout pairs (Method 4) is irreversible if a reorganization occurs at or before the transaction's block of inclusion, although this step is not mandatory for achieving compression.

The compression methods include packing metadata, employing variable-length integers and compact formats, using compressed signatures with public key recovery, and substituting txid/vout pairs with more size-efficient data. For example, Method 4 compresses the Txid only if the transaction input has surpassed a hundred-block threshold to avoid complications from block reorganizations.

The schema's core encompasses encoding instructions for primitives, the general schema, and metadata for transactions, inputs, and outputs. These involve CompactSize and VarInt encodings, VLP-Bytestreams for byte stream lengths, and specific script type encodings. An optimal transaction model is defined, illustrating the compression savings possible across multiple components.

The documentation on GitHub provides test vectors, detailing the compression effects on Taproot and Legacy transactions and demonstrating significant space savings. The provided hexadecimal strings suggest blockchain-related content, revealing differences between uncompressed and compressed formats, which likely contain transaction identifiers or other blockchain information.

For further details and technical insights, the full documentation is available at the provided GitHub link: Compressed Transaction Schema.