Skip to content

Commit

Permalink
Merge pull request #863 from nuttycom/add_orchard_to_transaction_builder
Browse files Browse the repository at this point in the history
Add Orchard to transaction builder
  • Loading branch information
str4d authored Jun 23, 2023
2 parents 06a7849 + 7fe02f0 commit 5e7eea7
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 55 deletions.
2 changes: 1 addition & 1 deletion zcash_client_backend/src/data_api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ where

// Create the transaction. The type of the proposal ensures that there
// are no possible transparent inputs, so we ignore those
let mut builder = Builder::new(params.clone(), proposal.target_height());
let mut builder = Builder::new(params.clone(), proposal.target_height(), None);

for selected in proposal.sapling_inputs() {
let (note, key, merkle_path) = select_key_for_note(selected, usk.sapling(), &dfvk)
Expand Down
2 changes: 2 additions & 0 deletions zcash_client_backend/src/fees/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ impl ChangeStrategy for SingleOutputChangeStrategy {
transparent_outputs,
sapling_inputs.len(),
sapling_outputs.len() + 1,
//Orchard is not yet supported in zcash_client_backend
0,
)
.unwrap(); // fixed::FeeRule::fee_required is infallible.

Expand Down
2 changes: 2 additions & 0 deletions zcash_client_backend/src/fees/zip317.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ impl ChangeStrategy for SingleOutputChangeStrategy {
// add one for Sapling change, then account for Sapling output padding performed by
// the transaction builder
std::cmp::max(sapling_outputs.len() + 1, 2),
//Orchard is not yet supported in zcash_client_backend
0,
)
.map_err(ChangeError::StrategyError)?;

Expand Down
2 changes: 2 additions & 0 deletions zcash_client_backend/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ mod tests {
#[test]
#[cfg(feature = "transparent-inputs")]
fn ufvk_derivation() {
use super::UnifiedSpendingKey;

for tv in test_vectors::UNIFIED {
let usk = UnifiedSpendingKey::from_seed(
&MAIN_NETWORK,
Expand Down
2 changes: 1 addition & 1 deletion zcash_extensions/src/transparent/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ mod tests {

fn demo_builder<'a>(height: BlockHeight) -> DemoBuilder<Builder<'a, FutureNetwork, OsRng>> {
DemoBuilder {
txn_builder: Builder::new(FutureNetwork, height),
txn_builder: Builder::new(FutureNetwork, height, None),
extension_id: 0,
}
}
Expand Down
31 changes: 29 additions & 2 deletions zcash_primitives/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Added
- `zcash_primitives::transaction::builder`:
- `Builder::add_orchard_spend`
- `Builder::add_orchard_output`
- `zcash_primitives::transaction::components::orchard::builder` module

### Changed
- `zcash_primitives::transaction`:
- `builder::Builder::{new, new_with_rng}` now take an optional `orchard_anchor`
argument which must be provided in order to enable Orchard spends and recipients.
- All `builder::Builder` methods now require the bound `R: CryptoRng` on
`Builder<'a, P, R>`. A non-`CryptoRng` randomness source is still accepted
by `builder::Builder::test_only_new_with_rng`, which **MUST NOT** be used in
production.
- `builder::Error` has several additional variants for Orchard-related errors.
- `fees::FeeRule::fee_required` now takes an additional argument,
`orchard_action_count`
- `Unauthorized`'s associated type `OrchardAuth` is now
`orchard::builder::InProgress<orchard::builder::Unproven, orchard::builder::Unauthorized>`
instead of `zcash_primitives::transaction::components::orchard::Unauthorized`
- `zcash_primitives::consensus::NetworkUpgrade` now implements `PartialEq`, `Eq`

### Removed
- `impl {PartialEq, Eq} for transaction::builder::Error`
(use `assert_matches!` where error comparisons are required)
- `zcash_primitives::transaction::components::orchard::Unauthorized`

## [0.12.0] - 2023-06-06
### Added
- `zcash_primitives::transaction`:
Expand All @@ -27,7 +54,7 @@ and this library adheres to Rust's notion of
`incrementalmerkletree::Hashable` and `merkle_tree::HashSer`.
- The `Hashable` bound on the `Node` parameter to the `IncrementalWitness`
type has been removed.
- `sapling::SAPLING_COMMITMENT_TREE_DEPTH_U8` and `sapling::SAPLING_COMMITMENT_TREE_DEPTH`
- `sapling::SAPLING_COMMITMENT_TREE_DEPTH_U8` and `sapling::SAPLING_COMMITMENT_TREE_DEPTH`
have been removed; use `sapling::NOTE_COMMITMENT_TREE_DEPTH` instead.
- `merkle_tree::{CommitmentTree, IncrementalWitness, MerklePath}` have been removed in
favor of versions of these types that are now provided by the
Expand Down Expand Up @@ -89,7 +116,7 @@ and this library adheres to Rust's notion of
- The bounds on the `H` parameter to the following methods have changed:
- `merkle_tree::incremental::read_frontier_v0`
- `merkle_tree::incremental::read_auth_fragment_v1`
- The depth of the `merkle_tree::{CommitmentTree, IncrementalWitness, and MerklePath}`
- The depth of the `merkle_tree::{CommitmentTree, IncrementalWitness, and MerklePath}`
data types are now statically constrained using const generic type parameters.
- `transaction::fees::fixed::FeeRule::standard()` now uses the ZIP 317 minimum fee
(10000 zatoshis rather than 1000 zatoshis) as the fixed fee. To be compliant with
Expand Down
2 changes: 1 addition & 1 deletion zcash_primitives/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl Parameters for Network {
/// consensus rules enforced by the network are altered.
///
/// See [ZIP 200](https://zips.z.cash/zip-0200) for more details.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NetworkUpgrade {
/// The [Overwinter] network upgrade.
///
Expand Down
Loading

0 comments on commit 5e7eea7

Please sign in to comment.