zcash_keys: Fix a few problems with no-flags compilation.
This commit is contained in:
parent
e78ea02240
commit
836d88b9c3
|
@ -9,6 +9,11 @@ and this library adheres to Rust's notion of
|
||||||
### Added
|
### Added
|
||||||
- `zcash_keys::keys::UnifiedAddressRequest::all`
|
- `zcash_keys::keys::UnifiedAddressRequest::all`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- A missing application of the `sapling` feature flag was remedied;
|
||||||
|
prior to this fix it was not possible to use this crate without the
|
||||||
|
`sapling` feature enabled.
|
||||||
|
|
||||||
## [0.1.0] - 2024-03-01
|
## [0.1.0] - 2024-03-01
|
||||||
The entries below are relative to the `zcash_client_backend` crate as of
|
The entries below are relative to the `zcash_client_backend` crate as of
|
||||||
`zcash_client_backend 0.10.0`.
|
`zcash_client_backend 0.10.0`.
|
||||||
|
|
|
@ -67,6 +67,7 @@ jubjub.workspace = true
|
||||||
proptest.workspace = true
|
proptest.workspace = true
|
||||||
rand_core.workspace = true
|
rand_core.workspace = true
|
||||||
zcash_address = { workspace = true, features = ["test-dependencies"] }
|
zcash_address = { workspace = true, features = ["test-dependencies"] }
|
||||||
|
zcash_primitives = { workspace = true, features = ["test-dependencies"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
## Enables use of transparent key parts and addresses
|
## Enables use of transparent key parts and addresses
|
||||||
|
|
|
@ -143,7 +143,11 @@ impl UnifiedAddress {
|
||||||
|
|
||||||
/// Returns whether this address has a Sapling receiver.
|
/// Returns whether this address has a Sapling receiver.
|
||||||
pub fn has_sapling(&self) -> bool {
|
pub fn has_sapling(&self) -> bool {
|
||||||
self.sapling.is_some()
|
#[cfg(not(feature = "sapling"))]
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#[cfg(feature = "sapling")]
|
||||||
|
return self.sapling.is_some();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the Sapling receiver within this Unified Address, if any.
|
/// Returns the Sapling receiver within this Unified Address, if any.
|
||||||
|
@ -213,6 +217,7 @@ impl UnifiedAddress {
|
||||||
let result = std::iter::empty();
|
let result = std::iter::empty();
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
let result = result.chain(self.orchard.map(|_| Typecode::Orchard));
|
let result = result.chain(self.orchard.map(|_| Typecode::Orchard));
|
||||||
|
#[cfg(feature = "sapling")]
|
||||||
let result = result.chain(self.sapling.map(|_| Typecode::Sapling));
|
let result = result.chain(self.sapling.map(|_| Typecode::Sapling));
|
||||||
let result = result.chain(self.transparent.map(|taddr| match taddr {
|
let result = result.chain(self.transparent.map(|taddr| match taddr {
|
||||||
TransparentAddress::PublicKeyHash(_) => Typecode::P2pkh,
|
TransparentAddress::PublicKeyHash(_) => Typecode::P2pkh,
|
||||||
|
@ -353,7 +358,7 @@ mod tests {
|
||||||
use zcash_address::test_vectors;
|
use zcash_address::test_vectors;
|
||||||
use zcash_primitives::consensus::MAIN_NETWORK;
|
use zcash_primitives::consensus::MAIN_NETWORK;
|
||||||
|
|
||||||
use super::Address;
|
use super::{Address, UnifiedAddress};
|
||||||
|
|
||||||
#[cfg(feature = "sapling")]
|
#[cfg(feature = "sapling")]
|
||||||
use crate::keys::sapling;
|
use crate::keys::sapling;
|
||||||
|
@ -361,9 +366,6 @@ mod tests {
|
||||||
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
||||||
use zcash_primitives::zip32::AccountId;
|
use zcash_primitives::zip32::AccountId;
|
||||||
|
|
||||||
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
|
||||||
use super::UnifiedAddress;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
||||||
fn ua_round_trip() {
|
fn ua_round_trip() {
|
||||||
|
|
|
@ -7,16 +7,16 @@ use zcash_primitives::{
|
||||||
|
|
||||||
use crate::address::UnifiedAddress;
|
use crate::address::UnifiedAddress;
|
||||||
|
|
||||||
#[cfg(feature = "transparent-inputs")]
|
|
||||||
use zcash_primitives::legacy::keys::NonHardenedChildIndex;
|
|
||||||
|
|
||||||
#[cfg(feature = "transparent-inputs")]
|
#[cfg(feature = "transparent-inputs")]
|
||||||
use {
|
use {
|
||||||
std::convert::TryInto,
|
std::convert::TryInto,
|
||||||
zcash_primitives::legacy::keys::{self as legacy, IncomingViewingKey},
|
zcash_primitives::legacy::keys::{self as legacy, IncomingViewingKey, NonHardenedChildIndex},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(feature = "test-dependencies", feature = "transparent-inputs"))]
|
#[cfg(all(
|
||||||
|
feature = "transparent-inputs",
|
||||||
|
any(test, feature = "test-dependencies")
|
||||||
|
))]
|
||||||
use zcash_primitives::legacy::TransparentAddress;
|
use zcash_primitives::legacy::TransparentAddress;
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
|
@ -847,13 +847,15 @@ pub mod testing {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::UnifiedFullViewingKey;
|
||||||
use proptest::prelude::proptest;
|
use proptest::prelude::proptest;
|
||||||
|
|
||||||
use super::UnifiedFullViewingKey;
|
#[cfg(any(
|
||||||
use zcash_primitives::consensus::MAIN_NETWORK;
|
feature = "orchard",
|
||||||
|
feature = "sapling",
|
||||||
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
feature = "transparent-inputs"
|
||||||
use zip32::AccountId;
|
))]
|
||||||
|
use {zcash_primitives::consensus::MAIN_NETWORK, zip32::AccountId};
|
||||||
|
|
||||||
#[cfg(feature = "sapling")]
|
#[cfg(feature = "sapling")]
|
||||||
use super::sapling;
|
use super::sapling;
|
||||||
|
@ -940,7 +942,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(not(any(feature = "orchard", feature = "sapling")))]
|
#[cfg(not(any(feature = "orchard", feature = "sapling")))]
|
||||||
assert_eq!(ufvk, None);
|
assert!(ufvk.is_none());
|
||||||
|
|
||||||
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
#[cfg(any(feature = "orchard", feature = "sapling"))]
|
||||||
{
|
{
|
||||||
|
@ -1055,6 +1057,7 @@ mod tests {
|
||||||
|
|
||||||
// The test vectors contain some diversifier indices that do not generate
|
// The test vectors contain some diversifier indices that do not generate
|
||||||
// valid Sapling addresses, so skip those.
|
// valid Sapling addresses, so skip those.
|
||||||
|
#[cfg(feature = "sapling")]
|
||||||
if ufvk.sapling().unwrap().address(d_idx).is_none() {
|
if ufvk.sapling().unwrap().address(d_idx).is_none() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1075,6 +1078,7 @@ mod tests {
|
||||||
if tvua.transparent().is_some() {
|
if tvua.transparent().is_some() {
|
||||||
assert_eq!(tvua.transparent(), ua.transparent());
|
assert_eq!(tvua.transparent(), ua.transparent());
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "sapling")]
|
||||||
if tvua.sapling().is_some() {
|
if tvua.sapling().is_some() {
|
||||||
assert_eq!(tvua.sapling(), ua.sapling());
|
assert_eq!(tvua.sapling(), ua.sapling());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue