Commit Graph

21 Commits

Author SHA1 Message Date
Jane Lusby 8281b9040c
Start work on new Amount type (#554) 2020-07-01 16:31:30 -07:00
Jane Lusby 6cbb6d4574
consolidate arbitrary impls to one file in zebra-chain (#553)
* consolidate arbitrary impls to one file in zebra-chain

* move the ones I missed

* move test-vectors

Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-06-30 14:23:38 -07:00
Henry de Valence a023ba9b16
Add serde bounds to zebra-chain structures. (#231) 2020-06-15 15:08:14 -07:00
Deirdre Connolly 955a4ebc3c Rename SpendDescription to Spend, OutputDescription to Output 2020-04-09 17:17:21 -04:00
Henry de Valence afa2c2347f fmt 2020-02-21 06:48:25 -05:00
Henry de Valence 2d2603cf65 Add a CoinbaseData field, replacing Vec<u8>.
The CoinbaseData field can only be constructed by the transaction parser, so we
can ensure that a coinbase input is always serializable, as CoinbaseData
instances can't be constructed outside of the parser that maintains the data
size invariant.
2020-02-19 15:42:20 -05:00
Henry de Valence 56d7391f6d Add convenience methods to Transaction.
Because we represent each transaction version as a different variant of the
Transaction enum, we end up in a situation where fields that are common to
different transaction versions are awkward to access, requiring a match
statement with identical match arms.

To fix this, this commit adds the following convenience methods:

* `Transaction::inputs() -> impl Iterator<Item=&TransparentInput>`;
* `Transaction::outputs() -> impl Iterator<Item=&TransparentOutput>`;
* `Transaction::lock_time() -> LockTime`;
* `Transaction::expiry_height() -> Option<ExpiryHeight>`;

The last returns an `Option` because the field is only present in V3 and V4
transactions.

There are some remaining fields that do not get common accessors, because it
probably doesn't make sense to access independently of knowing the transaction
version: `joinsplit_data`, `shielded_data`, `value_balance`.
2020-02-14 18:23:41 -05:00
Henry de Valence f04f4f0b98 Apply clippy fixes 2020-02-05 12:42:32 -08:00
Deirdre Connolly 3ea4a6a9ab Move transaction test vectors around
Resolves #210
2020-02-04 18:04:53 -05:00
Henry de Valence c26304d983 Correct an error in transaction modeling.
In the previous transaction modeling I defined the structs so that the number
of old and new commitments for a JoinSplit were variable, when in fact the
Sprout design fixes both to be 2.  So now they are hardcoded as 2 in the source
code as well.  This commit also fixes some missing `pub` fields on the
`JoinSplit` struct.
2019-12-31 02:46:39 -05:00
Henry de Valence c013895cd7 Update Transaction definition. (#105)
* Added a few more top-level fields for the Transaction struct

* Add a placeholder Script type.

This could alternately use bytes::Bytes to save some allocations
but I don't think this is important to get perfectly now.  In the future, we
will want to have all of the script handling code in the zebra-script crate,
but we will need to have a container type for an encoded script in zebra-chain,
because otherwise zebra-chain would depend on zebra-script and not the other
way around.

* Rename Transaction{Input,Output} -> Transparent{Input,Output}.

These are only *transparent* inputs and outputs, so by putting Transparent in
the name (instead of Transaction) it's more clear that a transaction's inputs
or outputs can also be shielded.

* Add a LockTime enum.

* First attempt at a Transaction enum.

This attempts to map the versioning and field presence rules into an ADT, so
that structurally invalid transactions (e.g., a BCTV14 proof in a Sapling
transaction) are unrepresentable.

* Update zebra-chain/src/transaction.rs

Co-Authored-By: Daira Hopwood <daira@jacaranda.org>

* Add fixme note on type refinement.

* Rename Transaction variants according to version.

* Split transaction.rs into submodules.

* Start filling in spend, output descriptions.

* Progress on JoinSplit data structures.

This has a lot of duplication and should really use generics to abstract over
Sprout-on-BCTV14 or Sprout-on-Groth16.

* Add data types for Bctv14 and Groth16 proofs.

This also adds a trait to abstract over them.

* Make JoinSplit descriptions generic over the proof system.

* Update zebra-chain/src/transaction/joinsplit.rs
2019-12-05 15:56:58 -05:00
Deirdre Connolly 51b888c0ff Impl custom Debug for TransactionHash
Resolves #104
2019-12-05 10:07:47 -08:00
Henry de Valence 47513b1ae7 Suppress warnings from stub functions.
This just replaces a bunch of variable names with underscored variants
while the function bodies are still `unimplemented!()`.
2019-09-30 21:32:57 -04:00
Henry de Valence 1323fa7af7 Update zebra-chain/src/transaction.rs 2019-09-27 19:22:34 -07:00
Deirdre Connolly 2739970113 Fill out TransactionHash and rename
Resolves #35
2019-09-27 19:22:34 -07:00
Deirdre Connolly b21b09bf8e Moved stub TxHash into zebra_chain::transaction 2019-09-27 19:22:34 -07:00
Deirdre Connolly b4b72829b2 Sanity: checked 2019-09-26 23:41:25 -04:00
Deirdre Connolly 6236909210 Update zebra-chain/src/transaction.rs
Co-Authored-By: Henry de Valence <hdevalence@hdevalence.ca>
2019-09-26 23:41:25 -04:00
Deirdre Connolly 38015c11a6 Add stubbed-out *NoteCommitmentTree* structs 2019-09-26 23:41:25 -04:00
Deirdre Connolly 90e5ae2f4b Add improved doc comments 2019-09-26 23:41:25 -04:00
Deirdre Connolly 73740841e1 Move `Transaction` and related types to their own module (#9)
* Move `Transaction` and related types to their own module

Resolves #6

* Fix references to `Transaction` after move
2019-09-19 07:45:37 -07:00