This section states the fee a wallet pays. It fixes the fee as a consensus quantity, defines the conventional fee of ZIP 317 over logical actions and bounds it before signing; it states the padded Action counts on which the fee is computed; and it states the relay, mempool and block-template rules that apply to a transaction paying less.
For a transaction other than a coinbase transaction, the transaction fee is the value remaining in its transparent transaction value pool: the sum of its transparent input values and of the balancing values of its shielded pools, minus the sum of its transparent output values (protocol specification, §“Transactions and Treestates”; Ironwood Guide, Definition “Transparent transaction value pool” and Definition “Balancing value”, in “The balancing value”). Consensus requires it to be non-negative. No transaction field encodes it, and every term of the sum is public, so the fee is public.
A fee rule for a shielded protocol meets the requirements of ZIP 317, “Requirements”: the fee is computable from the public data of the transaction alone, since a fee that depended on private construction data, such as which notes were spent or what change was returned, would disclose that data; it scales linearly with the numbers of inputs and outputs, which makes transaction-rate denial of service costly (ZIP 317, “Motivation” and “Denial of Service”); it neither penalises padding for privacy nor favours any pool; and it lets a small number of inputs of value below the marginal fee be spent. A fee other than the one every wallet pays distinguishes the wallet that chose it: non-standard fees may reveal specific users, wallets or wallet versions (ZIP 317, “Security and Privacy considerations”).
The conventional fee (Definition 10.2) is not a consensus rule. ZIP 317, “Fee calculation”, states that it is not a consensus requirement that fees follow the formula, and that wallets SHOULD create transactions that pay it, to reduce information leakage, unless overridden by the user. It binds through relay and block-template policy only (§10.3). ZIP 259, “NU7 consensus changes”, changes neither the formula nor its parameters.
In what follows, ⌈ x ⌉ is the least integer
Let a transaction of version 5 or version 6 have the following public fields of its final encoding (protocol specification, §“Transaction Encoding and Consensus”; ZIP 229, “Transaction Format”), each a non-negative integer:
tx _ in _ total _ size and tx _ out _ total _ size , the byte lengths of the encoded fields tx_in and tx_out , the concatenations of the encoded transparent inputs and outputs;
nJoinSplit , the number of Sprout JoinSplit descriptions;
nSpendsSapling and nOutputsSapling , the numbers of Sapling spend and output descriptions;
nActionsOrchard , the number of Orchard-pool Actions;
nActionsIronwood , the number of Ironwood-pool Actions, 0 in a version 5 transaction.
With the parameters
| logical _ actions := | max (⌈ tx _ in _ total _ size / 150 ⌉, ⌈ tx _ out _ total _ size / 34 ⌉) | ||
| + 2 nJoinSplit + max (nSpendsSapling, nOutputsSapling) | |||
| + nActionsOrchard + nActionsIronwood, |
the sum of the transparent, Sprout, Sapling, Orchard and Ironwood contributions, in that order (ZIP 317, “Fee calculation”, the contributions of Revision 0 and Revision 1 ).
The Sprout contribution 2 nJoinSplit is 0 in every valid transaction: transactions of version 5 and version 6 have no JoinSplit field, and transactions of version 4 are invalid under NU7 (ZIP 2003; ZIP 259, “NU7 consensus changes”). The term is kept so that the definition is that of ZIP 317. The two divisors are the maximal encoded sizes of a P2PKH input and output (ZIP 317, “Rationale for the chosen parameters”):
| 150 | = 36 (outpoint: 32 -byte txid, 4 -byte index) + 110 (script) + 4 (sequence), | ||
| 110 | = 1 (length) + 1 (signature length) + 72 (signature) + 1 (sighash type) | ||
| + 1 (key length) + 33 (compressed key) + 1 (margin), | |||
| 34 | = 8 (value) + 1 (script length) + 25 (P2PKH script) . |
Charging transparent parts by size rather than by count charges a large
script in proportion to its size, and a P2SH multisig input is counted so
(same section).
A 2-of-3 input with compressed keys has at most
Let
| conventional _ fee := marginal _ fee ⋅ max (grace _ actions, logical _ actions) zatoshi |
The parameter values and their rationale are ZIP 317’s (“Rationale for the chosen parameters”).
ZIP 317, “Fee calculation”, defines logical _ actions as the sum of the contributions of the applicable revision, and a contribution defined by a revision is included in every later one (ZIP 317, “Revisions”). Revision 0 defines the transparent, Sprout, Sapling and Orchard contributions. Revision 1 adds the Ironwood contribution nActionsIronwood : Ironwood-pool Actions have the Action structure of Orchard-pool Actions and are counted identically. Revision 2 adds a contribution for memo bundles (ZIP 231), defined on the transaction format of ZIP 248, which NU7 does not introduce (ZIP 259, “Rationale for no new transaction format”). Definition 10.1 is therefore Revision 0 with the Revision 1 term. The statuses of these ZIPs are those of Table 1.
Every transaction with
By Definition 10.2, since
A wallet computes the fee before it signs, and the encoded size of a transparent input depends on its signature. The following proposition bounds the fee from the unsigned transaction.
Let a wallet fix, before signing, every field of a transaction except the
scripts of its transparent inputs
otherwise any b i known to bound the encoded size of the signed input.
Let fee est be the conventional fee computed with tx _ in _ total _ size replaced by ∑ i = 1 k b i . Then fee est is at least the conventional fee of the signed transaction.
Signatures enter only the scripts of the transparent inputs, so the field
tx_out and every shielded count of
Definition 10.1 are the same in the unsigned and the
signed transaction. A DER-encoded signature has at most 72 bytes, so the
script of a P2PKH input with a compressed key has at most
Hypothesis (i) does not extend to a P2PKH input with an uncompressed
65 -byte key encoding, which has up to 181 bytes and needs
The fields of Definition 10.1 are those of the final encoded transaction: every bundle padded and every change output included (ZIP 317, “Fee calculation”). A wallet therefore prices a transaction by predicting its padded shape (Definition 10.6) and its change before it selects inputs; a fee computed on unpadded counts underpays whenever padding adds a logical action. This rule is ZIP 317’s and is not a consensus rule.
Let a bundle of the Orchard protocol, in the Orchard pool or the Ironwood
pool, have
| r (s, o) := { max (s, o) if enableCrossAddress = 1, s + o if enableCrossAddress = 0, |
and its padded Action count is
The count
The floor 2 and the Sapling padding are a padding policy, designed but unspecified in the sense of Definition 1.1. Their only general ZIP anchor is non-normative: ZIP 317, “Requirements”, notes that standard builders pad to two inputs and two outputs for each shielded pool, and “Rationale for the chosen parameters” calls padding to two actions the standard approach; ZIP 318 fixes the padding of its migration and note-preparation transactions only (below). The Sapling rule departs from ZIP 317’s remark by adding no spend beyond those needed. Dummy Sapling spends, which this policy does not use, are constructed as in protocol specification, §“Dummy Notes (Sapling)”; the dummy Actions of the Orchard protocol are those of §11.7. Logical actions count an Action once: a charge per input plus per output would penalise the padding that the Action structure forces, since each Action consumes one note and creates one, and the maximum in each contribution favours no pool (ZIP 317, “Rationale for logical actions”).
ZIP 318 specifies two exceptions. Under “Canonical migration transaction
structure”, a canonical migration transaction has one Orchard-pool spend in
an Orchard-pool bundle of exactly two Actions, one spend Action and one
output Action that carries either change or a zero-valued dummy output (ZIP
318, “Rationale for the canonical transaction shape”), and one
Ironwood-pool output in an unpadded Ironwood-pool bundle of one Action. Its
logical _ actions is 3 and its conventional fee
Consider a transaction with no transparent inputs or outputs, one input note and one payment output, with or without one change output, whose bundles are padded as in Definition 10.6.
If the input note and every output lie in the Ironwood pool, in a
bundle with
If the input is a single Orchard-pool note, the payment output lies in
the Ironwood pool, and the change output, if any, lies in the Orchard pool
or the Ironwood pool, then the conventional fee is
(a) In the Ironwood pool
(b) No value enters the Orchard pool, since
The conventional fee binds through three mechanisms, none of them a consensus rule. Nodes that normally relay transactions are expected to relay those paying at least the conventional fee, unless other reasons of robustness or denial-of-service mitigation apply (ZIP 317, “Transaction relaying”). Mempool size limiting adds a penalty low _ fee _ penalty to the eviction weight of a transaction paying less than the conventional fee (ZIP 401; ZIP 317, “Mempool size limiting”). Block-template construction limits the unpaid actions of a block (Definition 10.8).
For a transaction tx with fee tx . fee as in
§10.1 and tx . logical _ actions as in
Definition 10.1, the number of unpaid actions is
| unpaid _ actions (tx) | := max (0, max (grace _ actions, tx . logical _ actions) | ||
| − ⌊ tx . fee / marginal _ fee ⌋) . |
The unpaid actions of a block are the sum over its transactions. The
recommended block-template algorithm adds a transaction that pays less than
the conventional fee only while that sum stays at most
A transaction other than a coinbase transaction has
Let
A transaction with more than
A logical action is not the unit of the block limits of ZIP 218,
“Shielded pool action limits”: these count the sum