-
Notifications
You must be signed in to change notification settings - Fork 228
Add ZIP-0244 TxId Digest support #2129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
432d803
Add ZIP-0244 TxId Digest support
conradoplg 1e46971
Implement Arbitrary for Sapling and Orchard verification keys, Saplin…
conradoplg ba7119a
improve Arbitrary implementations to avoid prop_filter
conradoplg 17a0afc
Apply suggestions from code review
conradoplg 9529d87
Apply suggestions from code review
conradoplg 29b13a0
Improvements from code review
conradoplg 92378a6
Rename txidhash.rs -> txid.rs; TxIdHasher -> TxIdBuilder
conradoplg 8cb3036
Update zebra-chain/src/transaction/tests/vectors.rs
conradoplg 48a9680
Fix typo
dconnolly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| //! Contains code that interfaces with the zcash_primitives crate from | ||
| //! librustzcash. | ||
|
|
||
| use std::{ | ||
| convert::{TryFrom, TryInto}, | ||
| io, | ||
| }; | ||
|
|
||
| use crate::{serialization::ZcashSerialize, transaction::Transaction}; | ||
|
|
||
| impl TryFrom<&Transaction> for zcash_primitives::transaction::Transaction { | ||
| type Error = io::Error; | ||
|
|
||
| /// Convert a Zebra transaction into a librustzcash one. | ||
| /// | ||
| /// # Panics | ||
| /// | ||
| /// If the transaction is not V5. (Currently there is no need for this | ||
| /// conversion for other versions.) | ||
| fn try_from(trans: &Transaction) -> Result<Self, Self::Error> { | ||
| let network_upgrade = match trans { | ||
| Transaction::V5 { | ||
| network_upgrade, .. | ||
| } => network_upgrade, | ||
| Transaction::V1 { .. } | ||
| | Transaction::V2 { .. } | ||
| | Transaction::V3 { .. } | ||
| | Transaction::V4 { .. } => panic!("Zebra only uses librustzcash for V5 transactions"), | ||
| }; | ||
|
|
||
| let serialized_tx = trans.zcash_serialize_to_vec()?; | ||
| // The `read` method currently ignores the BranchId for V5 transactions; | ||
| // but we use the correct BranchId anyway. | ||
| let branch_id: u32 = network_upgrade | ||
| .branch_id() | ||
| .expect("Network upgrade must have a Branch ID") | ||
| .into(); | ||
| // We've already parsed this transaction, so its network upgrade must be valid. | ||
| let branch_id: zcash_primitives::consensus::BranchId = branch_id | ||
| .try_into() | ||
| .expect("zcash_primitives and Zebra have the same branch ids"); | ||
| let alt_tx = | ||
| zcash_primitives::transaction::Transaction::read(&serialized_tx[..], branch_id)?; | ||
| Ok(alt_tx) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.