In some circumstances, Bitcoin transactions are created that depend on each other, and for various reasons some do not get confirmed by the miners or even transmitted by the network of nodes.
The developer Gloria Zhao elaborated the proposal Package Relayformally in the bitcoin developer mailing list on May 17, 2022, to reduce the rate of unconfirmed transactions in Bitcoin and, in addition, mitigate security risks in second-layer solutions such as Lightning.
The “transmission of packets” is the basic concept of this proposal, and as its name suggests, it seeks to ensure that the nodes of the Bitcoin network can manipulate and transmit groups of transactions that are related to each other.
This can prevent some individual transactions from going unconfirmed, or not being confirmed on time due to not having paid a commission according to the minimum required at a given time.
Specifically, these transactions can remain in the air in the so-called Child Pays For Parents (CPFP, Children pay for parents), a type of transaction that spends the coins sent by a previous transaction, but paying a higher commission so that there are incentives among miners to confirm both.
The concept of “Package Relay” has been talked about for at least 7 or 9 years, and it is the concept of requesting, announcing and downloading groups of transactions together, transactions related to each other. A package [paquete] is a term widely used to refer to a group of transactions that have a dependency relationship, where there is a connection between a transaction that is spending the output of another transaction, be it a child and a parent, a parent with many children, a grandfather, a father and a son, etc.
Gloria Zhao, Bitcoin developer.
Why can a Bitcoin transaction go unconfirmed?
Sometimes, a transaction that does not qualify for payment of commissions can be ignored by the mempool of Bitcoin nodesbut if a “child” transaction with a high enough fee enters the mempool, it would be orphaned since the nodes are not aware of its “parent” transaction.
Considering the entry of transactions to the mempool individually creates a limitation in the ability of the node to determine which transactions have the highest commissions, since they are not taking into account the descendants until they reach the mempool […]
When a user’s transaction does not meet the minimum fee accepted by the mempool and they cannot create a replacement transaction directly, their transaction will be rejected by the mempool. They will also not be able to add a downstream transaction to pay the fees for the conflicting transaction. This limitation affects the ability of users to raise their transaction fees..
Gloria Zhao, Bitcoin developer.
Gloria Zhao explains in an interview in the podcast Chaincode Labs, an organization that provides educational and financial support to Bitcoin developers, what are the two main use cases of Package Relay.
There are two main use cases that are most talked about. One is to increase the fees of a parent or a transaction that doesn’t meet the minimum fees by itself, but has a child or descendant that incentivizes miners to include the parent in a block, because that means they can mine also to their descendants
The other most talked about use case is orphan fetching. An orphan is a transaction that spends inputs [inputs] that a specific node is not aware of. Sometimes it is an input that does not exist, but more often this transaction is spending an output of an unconfirmed transaction that was transmitted a few hours ago, only this node was not aware of it..
What changes does Package Relay bring to Bitcoin?
The Package Relay proposal introduces, among other changes, a set of messages that can be used by Bitcoin nodes, as explained in the bulletin of Bitcoin Optech.
The first message is “sendpackages”, which allows two nodes to negotiate the characteristics of transaction packets that they are willing to receive.
The second message is “getpckgtxns”, so “getpackagetransactions” (get package transactions), which requests another node for announced transactions in a package.
Then, the third message is the one that delivers the transactions that are part of the package, and is called “pckgtxns”.
Fourth, there is “pckginfo1”, which as its name indicates, provides information about the package, specifically how many transactions it includes, what is the serial of each transaction (txid), the weight or size of the transactions and the total commissions. “In this way, the commission rate of the package can be calculated by dividing the commissions of each by their weight,” they explain.
Being on time is important to Lightning
Second-layer solutions like Lightning rely on on-chain transmission and confirmation of transactions (on-chain) on time. For example, when closing a Lightning channel between two nodes, a user could lose their funds if their closing transaction is not confirmed on time, giving the other user the opportunity to send a transaction with a better commission and to be confirmed on time, and to leave the channel balanced with more bitcoins in their favor.
This scenario is basically feasible using what is known as pin attack, or hang attack (according to its rough translation), as it takes advantage of a frozen or hung transaction.
Pinning attack which is a type of censorship attack on unconfirmed transactions where it takes advantage of the fact that there are no guarantees that this transaction will propagate and some policies of the mempool, to prevent the transaction from reaching the mempool or from being put waiting to be confirmed.
Gloria Zhao, Bitcoin developer.
The developer also establishes in the interview that this attack is mostly possible when a low commission is set at the time of signing a transaction, but if at the time of closing the channel the average mempool commission is higher, the transaction could present a counterproductive delay.
Package Relay has other facets that we will explore in CriptoNoticias later, but that are already being reviewed and discussed by other Bitcoin developers.
Recently Gloria Zhao received a scholarship worth USD 150,000, We report here, and their work on improving the Bitcoin mempool is expected to continue beyond Package Relay.