Skip to main content

v4_empty_sapling_value_balance

Function v4_empty_sapling_value_balance 

Source
fn v4_empty_sapling_value_balance(
    raw_bytes: &[u8],
    inner: &Transaction,
) -> Option<i64>
Expand description

Reads the valueBalanceSapling field of a V4 transaction that has no Sapling spends or outputs, from the bytes that were consumed while parsing it.

Returns None if the bytes do not have the expected shape, in which case the caller should not treat the transaction as having a bad balance — a malformed encoding would already have failed to parse.

§Layout

The caller has established that the Sapling bundle is empty, which on the wire means nSpendsSapling and nOutputsSapling are both the single byte 0x00, and that no bindingSigSapling follows. So the tail of a V4 transaction is:

.. | valueBalanceSapling (8) | 0x00 | 0x00 | nJoinSplit | vJoinSplit.. | [pubkey | sig]

Locating the field from the end of the transaction avoids re-parsing the variable-length transparent inputs and outputs that precede it.