Beersy
BRC-30

Transaction Extended Format (EF)

A transaction on its own does not carry enough to check that its signatures are valid: the amounts and locks being spent live in earlier transactions. This adds those missing pieces, so a service can validate what it is given without looking anything up.

No author credited4 min read
ef markerinput with pre

Summary

Why
A service validating a transaction cannot check its signatures or fees without first looking up the amount and of every output it spends, which normally means an extra round trip to a Bitcoin node.
What
BRC-30 defines an Extended Format (EF) for serializing a Bitcoin transaction that embeds the previous locking script and satoshi amount directly into each input.
How
A wallet or library that already has the previous output data (needed anyway to sign the inputs) writes a special marker after the version number and appends each input's previous satoshi value and locking script, producing a transaction a broadcast service can validate without any external lookup.

What this lets you do

  • Serialize a transaction with locking scripts and amounts inlined per input
  • Let a broadcast service validate signatures and fees without querying a node
  • Detect extended-format transactions via the 0000000000EF marker
  • Avoid breaking legacy parsers, which read the marker as an empty future-locked transaction
  • Build transactions extended-format from the start with no extra signing work

Written by claude-sonnet-5 from the specification text. Where the two differ, the original is correct.

Reference for an AI

Everything an assistant needs to answer questions about BRC-30 accurately, including what it depends on.

The specification

Abstract

Regular Bitcoin transactions do not contain all the data that is needed to verify that the signatures in the transactions are valid. To sign an input of a Bitcoin transaction, the signer needs to know the transaction ID, output index, output and the of the input transaction. When sending a Bitcoin transaction to a node, only the previous transaction ID and the output index are part of the serialized transaction, the node will look up the locking script and output amount of the input transaction.

We propose an Extended Format (EF) for a Bitcoin transaction, that includes the locking script and the amount in satoshis of all inputs of the transaction. This allows a broadcast service to validate all aspects of a transaction without having to contact a node or an indexer for the utxos of the inputs of a transaction, speeding up the validation.

This BRC is licensed under the Open BSV license.

Motivation

Verifying that a transaction is valid, including all signatures, is not possible at the moment without getting the (utxos) from the transactions that are used as inputs from a Bitcoin node (or a Bitcoin indexer). This lookup of the utxos always happens inside a Bitcoin node when validating a transaction, but for a broadcast service to be able to fully validate a transaction (including the fee being paid) it also needs to look up the utxos being spent, which complicates scalability, since this lookup needs to happen on a node (via RPC), that might be too busy to react within an acceptable time frame.

A broadcast service would be able to validate a transaction almost in full if the sender would also send the missing data (previous locking scripts and satoshi outputs) from the utxos being used in the transaction. When creating a new transaction, the previous locking scripts and satoshi outputs are needed to be able to properly sign the transaction, so the missing data is available at the time of the transaction creation. Serializing the transaction to Extended Format, instead of the standard format, is at the point of creating the transaction no extra work, but does make it much easier for a broadcast service to validate the transaction when being received, before sending the transaction to a node.

The main motivation for this proposal is therefore scalability. When incoming transactions contain all the data that is needed to validate them, without having to contact an external service for missing data, the broadcast service becomes much more scalable.

Specification

Current Transaction format:

FieldDescriptionSize
Version nocurrently 24 bytes
In-counterpositive integer VI = [[VarInt]]1 - 9 bytes
list of inputsTransaction Input Structure<in-counter> qty with variable length per input
Out-counterpositive integer VI = [[VarInt]]1 - 9 bytes
list of outputsTransaction Output Structure<out-counter> qty with variable length per output
if non-zero and sequence numbers are < 0xFFFFFFFF: block height or timestamp when transaction is final4 bytes

The Extended Format adds a marker to the transaction format:

FieldDescriptionSize
Version nocurrently 24 bytes
EF markermarker for extended format0000000000EF
In-counterpositive integer VI = [[VarInt]]1 - 9 bytes
list of inputsExtended Format transaction Input Structure<in-counter> qty with variable length per input
Out-counterpositive integer VI = [[VarInt]]1 - 9 bytes
list of outputsTransaction Output Structure<out-counter> qty with variable length per output
nLocktimeif non-zero and sequence numbers are < 0xFFFFFFFF: block height or timestamp when transaction is final4 bytes

The Extended Format marker allows a library that supports the format to recognize that it is dealing with a transaction in extended format, while a library that does not support extended format will read the transaction as having 0 inputs, 0 outputs and a future nLock time. This has been done to minimize the possible problems a legacy library will have when reading the extended format. It can in no way be recognized as a valid transaction.

The input structure is the only additional thing that is changed in the Extended Format. The current input structure looks like this:

FieldDescriptionSize
Previous Transaction hashTXID of the transaction the output was created in32 bytes
Previous Txout-indexIndex of the output (Non negative integer)4 bytes
Txin-script lengthNon negative integer VI = VarInt1 - 9 bytes
Txin-script / scriptSigScript<in-script length>-many bytes
Sequence_noUsed to iterate inputs inside a payment channel. Input is final when = 0xFFFFFFFF4 bytes

In the Extended Format, we extend the input structure to include the previous locking script and satoshi outputs:

FieldDescriptionSize
Previous Transaction hashTXID of the transaction the output was created in32 bytes
Previous Txout-indexIndex of the output (Non negative integer)4 bytes
Txin-script lengthNon negative integer VI = VarInt1 - 9 bytes
Txin-script / scriptSigScript<in-script length>-many bytes
Sequence_noUsed to iterate inputs inside a payment channel. Input is final when nSequence = 0xFFFFFFFF4 bytes
Previous TX satoshi outputOutput value in satoshis of previous input4 bytes
Previous TX script lengthNon negative integer VI = VarInt1 - 9 bytes
Previous TX locking scriptScript<script length>-many bytes

Backward compatibility

The Extended Format is not backwards compatible, but has been designed in such a way that existing software should not read a transaction in Extend Format as a valid (partial) transaction. The Extended Format header (0000000000EF) will be read as an empty transaction with a future nLock time in a library that does not support the Extended Format.

Implementation

The Extended Format has been implemented in go-bt and a standalone JavaScript library bitcoin-ef.

<pre> BIP: 239 Layer: Applications Title: Transaction Extended Format (TEF) Author: Simon Ordish (@ordishs) Siggi Oskarsson (@icellan) Comments-Summary: No comments yet. Comments-URI: - Status: Proposal Type: Standards Track Created: 2022-11-09 </pre>
Was this helpful?

Search Beersy

Search standards by number, title, author or topic