zcash_client_sqlite: Do not request transparent UA components if "transparent-inputs" feature is disabled.
This commit is contained in:
parent
45df8b7853
commit
7c0b9da9b7
|
@ -107,8 +107,13 @@ pub(crate) const VERIFY_LOOKAHEAD: u32 = 10;
|
||||||
|
|
||||||
pub(crate) const SAPLING_TABLES_PREFIX: &str = "sapling";
|
pub(crate) const SAPLING_TABLES_PREFIX: &str = "sapling";
|
||||||
|
|
||||||
pub const DEFAULT_UA_REQUEST: UnifiedAddressRequest =
|
#[cfg(not(feature = "transparent-inputs"))]
|
||||||
UnifiedAddressRequest::unsafe_new(false, true, true);
|
pub(crate) const UA_TRANSPARENT: bool = false;
|
||||||
|
#[cfg(feature = "transparent-inputs")]
|
||||||
|
pub(crate) const UA_TRANSPARENT: bool = true;
|
||||||
|
|
||||||
|
pub(crate) const DEFAULT_UA_REQUEST: UnifiedAddressRequest =
|
||||||
|
UnifiedAddressRequest::unsafe_new(false, true, UA_TRANSPARENT);
|
||||||
|
|
||||||
/// A newtype wrapper for received note identifiers.
|
/// A newtype wrapper for received note identifiers.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
|
|
@ -398,6 +398,8 @@ mod tests {
|
||||||
use zcash_client_backend::keys::UnifiedAddressRequest;
|
use zcash_client_backend::keys::UnifiedAddressRequest;
|
||||||
use zcash_primitives::transaction::components::amount::NonNegativeAmount;
|
use zcash_primitives::transaction::components::amount::NonNegativeAmount;
|
||||||
|
|
||||||
|
use crate::UA_TRANSPARENT;
|
||||||
|
|
||||||
let network = Network::TestNetwork;
|
let network = Network::TestNetwork;
|
||||||
let data_file = NamedTempFile::new().unwrap();
|
let data_file = NamedTempFile::new().unwrap();
|
||||||
let mut db_data = WalletDb::for_path(data_file.path(), network).unwrap();
|
let mut db_data = WalletDb::for_path(data_file.path(), network).unwrap();
|
||||||
|
@ -438,7 +440,11 @@ mod tests {
|
||||||
|
|
||||||
let usk = UnifiedSpendingKey::from_seed(&network, &[0u8; 32][..], AccountId::ZERO).unwrap();
|
let usk = UnifiedSpendingKey::from_seed(&network, &[0u8; 32][..], AccountId::ZERO).unwrap();
|
||||||
let ufvk = usk.to_unified_full_viewing_key();
|
let ufvk = usk.to_unified_full_viewing_key();
|
||||||
let (ua, _) = ufvk.default_address(UnifiedAddressRequest::unsafe_new(false, true, true));
|
let (ua, _) = ufvk.default_address(UnifiedAddressRequest::unsafe_new(
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
UA_TRANSPARENT,
|
||||||
|
));
|
||||||
let taddr = ufvk
|
let taddr = ufvk
|
||||||
.transparent()
|
.transparent()
|
||||||
.and_then(|k| {
|
.and_then(|k| {
|
||||||
|
|
|
@ -8,7 +8,10 @@ use zcash_client_backend::{address::Address, keys::UnifiedFullViewingKey};
|
||||||
use zcash_keys::keys::UnifiedAddressRequest;
|
use zcash_keys::keys::UnifiedAddressRequest;
|
||||||
use zcash_primitives::{consensus, zip32::AccountId};
|
use zcash_primitives::{consensus, zip32::AccountId};
|
||||||
|
|
||||||
use crate::wallet::{init::WalletMigrationError, insert_address};
|
use crate::{
|
||||||
|
wallet::{init::WalletMigrationError, insert_address},
|
||||||
|
UA_TRANSPARENT,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "transparent-inputs")]
|
#[cfg(feature = "transparent-inputs")]
|
||||||
use zcash_primitives::legacy::keys::IncomingViewingKey;
|
use zcash_primitives::legacy::keys::IncomingViewingKey;
|
||||||
|
@ -85,8 +88,11 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
|
||||||
"Address in accounts table was not a Unified Address.".to_string(),
|
"Address in accounts table was not a Unified Address.".to_string(),
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
let (expected_address, idx) =
|
let (expected_address, idx) = ufvk.default_address(UnifiedAddressRequest::unsafe_new(
|
||||||
ufvk.default_address(UnifiedAddressRequest::unsafe_new(false, true, true));
|
false,
|
||||||
|
true,
|
||||||
|
UA_TRANSPARENT,
|
||||||
|
));
|
||||||
if decoded_address != expected_address {
|
if decoded_address != expected_address {
|
||||||
return Err(WalletMigrationError::CorruptedData(format!(
|
return Err(WalletMigrationError::CorruptedData(format!(
|
||||||
"Decoded UA {} does not match the UFVK's default address {} at {:?}.",
|
"Decoded UA {} does not match the UFVK's default address {} at {:?}.",
|
||||||
|
@ -156,8 +162,11 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
|
||||||
],
|
],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (address, d_idx) =
|
let (address, d_idx) = ufvk.default_address(UnifiedAddressRequest::unsafe_new(
|
||||||
ufvk.default_address(UnifiedAddressRequest::unsafe_new(false, true, true));
|
false,
|
||||||
|
true,
|
||||||
|
UA_TRANSPARENT,
|
||||||
|
));
|
||||||
insert_address(transaction, &self.params, account, d_idx, &address)?;
|
insert_address(transaction, &self.params, account, d_idx, &address)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,12 @@ use zcash_primitives::legacy::keys::IncomingViewingKey;
|
||||||
#[cfg(feature = "transparent-inputs")]
|
#[cfg(feature = "transparent-inputs")]
|
||||||
use zcash_client_backend::encoding::AddressCodec;
|
use zcash_client_backend::encoding::AddressCodec;
|
||||||
|
|
||||||
use crate::wallet::{
|
use crate::{
|
||||||
|
wallet::{
|
||||||
init::{migrations::initial_setup, WalletMigrationError},
|
init::{migrations::initial_setup, WalletMigrationError},
|
||||||
pool_code,
|
pool_code,
|
||||||
|
},
|
||||||
|
UA_TRANSPARENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xbe57ef3b_388e_42ea_97e2_678dafcf9754);
|
pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xbe57ef3b_388e_42ea_97e2_678dafcf9754);
|
||||||
|
@ -65,7 +68,7 @@ impl<P: consensus::Parameters> RusqliteMigration for Migration<P> {
|
||||||
let mut stmt_fetch_accounts =
|
let mut stmt_fetch_accounts =
|
||||||
transaction.prepare("SELECT account, address FROM accounts")?;
|
transaction.prepare("SELECT account, address FROM accounts")?;
|
||||||
|
|
||||||
let ua_request = UnifiedAddressRequest::new(false, true, true)
|
let ua_request = UnifiedAddressRequest::new(false, true, UA_TRANSPARENT)
|
||||||
.expect("A shielded receiver type is requested.");
|
.expect("A shielded receiver type is requested.");
|
||||||
let mut rows = stmt_fetch_accounts.query([])?;
|
let mut rows = stmt_fetch_accounts.query([])?;
|
||||||
while let Some(row) = rows.next()? {
|
while let Some(row) = rows.next()? {
|
||||||
|
|
Loading…
Reference in New Issue