zcash_primitives: Temporarily expose v5 Sapling bundle parsing
This is currently exposed via `Transaction` for usage in `zcashd`, but may be removed in future (if `zcashd` moves transaction parsing entirely into Rust), or renamed and stabilised.
This commit is contained in:
parent
62bc15ccf0
commit
26d95b4a0e
|
@ -6,6 +6,11 @@ and this library adheres to Rust's notion of
|
||||||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
- `zcash_primitives::transaction`:
|
||||||
|
- `Transaction::temporary_zcashd_read_v5_sapling`
|
||||||
|
- `Transaction::temporary_zcashd_write_v5_sapling`
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Bumped dependencies to `secp256k1 0.26`, `hdwallet 0.4`.
|
- Bumped dependencies to `secp256k1 0.26`, `hdwallet 0.4`.
|
||||||
- `zcash_primitives::transactions::component::amount::DEFAULT_FEE` increased zip317
|
- `zcash_primitives::transactions::component::amount::DEFAULT_FEE` increased zip317
|
||||||
|
|
|
@ -730,6 +730,13 @@ impl Transaction {
|
||||||
Ok((consensus_branch_id, lock_time, expiry_height))
|
Ok((consensus_branch_id, lock_time, expiry_height))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "temporary-zcashd")]
|
||||||
|
pub fn temporary_zcashd_read_v5_sapling<R: Read>(
|
||||||
|
reader: R,
|
||||||
|
) -> io::Result<Option<sapling::Bundle<sapling::Authorized>>> {
|
||||||
|
Self::read_v5_sapling(reader)
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
fn read_v5_sapling<R: Read>(
|
fn read_v5_sapling<R: Read>(
|
||||||
mut reader: R,
|
mut reader: R,
|
||||||
|
@ -917,8 +924,23 @@ impl Transaction {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_v5_sapling<W: Write>(&self, mut writer: W) -> io::Result<()> {
|
#[cfg(feature = "temporary-zcashd")]
|
||||||
if let Some(bundle) = &self.sapling_bundle {
|
pub fn temporary_zcashd_write_v5_sapling<W: Write>(
|
||||||
|
sapling_bundle: Option<&sapling::Bundle<sapling::Authorized>>,
|
||||||
|
writer: W,
|
||||||
|
) -> io::Result<()> {
|
||||||
|
Self::write_v5_sapling_inner(sapling_bundle, writer)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write_v5_sapling<W: Write>(&self, writer: W) -> io::Result<()> {
|
||||||
|
Self::write_v5_sapling_inner(self.sapling_bundle.as_ref(), writer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_v5_sapling_inner<W: Write>(
|
||||||
|
sapling_bundle: Option<&sapling::Bundle<sapling::Authorized>>,
|
||||||
|
mut writer: W,
|
||||||
|
) -> io::Result<()> {
|
||||||
|
if let Some(bundle) = sapling_bundle {
|
||||||
Vector::write(&mut writer, bundle.shielded_spends(), |w, e| {
|
Vector::write(&mut writer, bundle.shielded_spends(), |w, e| {
|
||||||
e.write_v5_without_witness_data(w)
|
e.write_v5_without_witness_data(w)
|
||||||
})?;
|
})?;
|
||||||
|
|
Loading…
Reference in New Issue