Zebra/zebra-consensus/src
Janito Vaqueiro Ferreira Filho b44d81669f
Move the check in `transaction::check::sapling_balances_match` to `V4` deserialization (#2234)
* Implement `PartialEq<i64>` for `Amount`

Allows to compare an `Amount` instance directly to an integer.

* Add `SerializationError::BadTransactionBalance`

Error variant representing deserialization of a transaction that doesn't
conform to the Sapling consensus rule where the balance MUST be zero if
there aren't any shielded spends and outputs.

* Validate consensus rule when deserializing

Return an error if the deserialized V4 transaction has a non-zero value
balance but doesn't have any Sapling shielded spends nor outputs.

* Add consensus rule link to field documentation

Describe how the consensus rule is validated structurally by
`ShieldedData`.

* Clarify that `value_balance` is zero

Make the description more concise and objective.

Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>

* Update field documentation

Include information about how the consensus rule is guaranteed during
serialization.

Co-authored-by: teor <teor@riseup.net>

* Remove `check::sapling_balances_match` function

The check is redundant because the respective consensus rule is
validated structurally by `ShieldedData`.

* Test deserialization of invalid V4 transaction

A transaction with no Sapling shielded spends and no outputs but with a
non-zero balance value should fail to deserialize.

* Change least-significant byte of the value balance

State how the byte index is calculated, and change the least
significant-byte to be non-zero.

Co-authored-by: teor <teor@riseup.net>
2021-06-04 08:53:00 +10:00
..
block Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
chain Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
checkpoint Make sure the mandatory checkpoint includes Canopy activation (#2235) 2021-06-03 10:24:08 +10:00
parameters Replace smart quotes with ascii quotes 2021-03-15 03:18:10 -04:00
primitives Rename shielded_data to sapling_shielded_data as needed (#2072) 2021-04-27 10:37:53 -03:00
transaction Move the check in `transaction::check::sapling_balances_match` to `V4` deserialization (#2234) 2021-06-04 08:53:00 +10:00
block.rs Validate nConsensusBranchId (#2100) 2021-05-10 01:31:45 +00:00
chain.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
checkpoint.rs Validate nConsensusBranchId (#2100) 2021-05-10 01:31:45 +00:00
config.rs Make sure the mandatory checkpoint includes Canopy activation (#2235) 2021-06-03 10:24:08 +10:00
error.rs Update `transaction::check::coinbase_tx_no_joinsplit_or_spend` to validate V5 coinbase transactions with Orchard shielded data (#2236) 2021-06-03 01:54:08 +00:00
lib.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
parameters.rs move genesis parameters to zebra-chain (#1151) 2020-10-12 14:08:23 -07:00
primitives.rs Ed25519 async batch verification for JoinSplit signatures (#1952) 2021-03-31 09:08:19 +10:00
script.rs Make the state usage clearer in script::Verifier (#1733) 2021-02-16 05:53:12 +10:00
transaction.rs Move the check in `transaction::check::sapling_balances_match` to `V4` deserialization (#2234) 2021-06-04 08:53:00 +10:00