Add mainnet support to zcash_client_sqlite via a feature flag
This commit is contained in:
@@ -2,15 +2,13 @@
|
||||
|
||||
use rusqlite::{types::ToSql, Connection, NO_PARAMS};
|
||||
use std::path::Path;
|
||||
use zcash_client_backend::{
|
||||
constants::testnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
|
||||
encoding::encode_extended_full_viewing_key,
|
||||
};
|
||||
use zcash_client_backend::encoding::encode_extended_full_viewing_key;
|
||||
use zcash_primitives::{block::BlockHash, zip32::ExtendedFullViewingKey};
|
||||
|
||||
use crate::{
|
||||
address_from_extfvk,
|
||||
error::{Error, ErrorKind},
|
||||
HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
|
||||
};
|
||||
|
||||
/// Sets up the internal structure of the cache database.
|
||||
@@ -243,16 +241,14 @@ pub fn init_blocks_table<P: AsRef<Path>>(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use tempfile::NamedTempFile;
|
||||
use zcash_client_backend::{
|
||||
constants::testnet::HRP_SAPLING_PAYMENT_ADDRESS, encoding::decode_payment_address,
|
||||
};
|
||||
use zcash_client_backend::encoding::decode_payment_address;
|
||||
use zcash_primitives::{
|
||||
block::BlockHash,
|
||||
zip32::{ExtendedFullViewingKey, ExtendedSpendingKey},
|
||||
};
|
||||
|
||||
use super::{init_accounts_table, init_blocks_table, init_data_database};
|
||||
use crate::query::get_address;
|
||||
use crate::{query::get_address, HRP_SAPLING_PAYMENT_ADDRESS};
|
||||
|
||||
#[test]
|
||||
fn init_accounts_table_only_works_once() {
|
||||
|
||||
@@ -16,16 +16,29 @@
|
||||
//! **MUST NOT** write to the database without using these APIs. Callers **MAY** read
|
||||
//! the database directly in order to extract information for display to users.
|
||||
//!
|
||||
//! # Features
|
||||
//!
|
||||
//! The `mainnet` feature configures the light client for use with the Zcash mainnet. By
|
||||
//! default, the light client is configured for use with the Zcash testnet.
|
||||
//!
|
||||
//! [`CompactBlock`]: zcash_client_backend::proto::compact_formats::CompactBlock
|
||||
//! [`init_cache_database`]: crate::init::init_cache_database
|
||||
|
||||
use rusqlite::{Connection, NO_PARAMS};
|
||||
use std::cmp;
|
||||
use zcash_client_backend::{
|
||||
constants::testnet::HRP_SAPLING_PAYMENT_ADDRESS, encoding::encode_payment_address,
|
||||
};
|
||||
use zcash_client_backend::encoding::encode_payment_address;
|
||||
use zcash_primitives::zip32::ExtendedFullViewingKey;
|
||||
|
||||
#[cfg(feature = "mainnet")]
|
||||
use zcash_client_backend::constants::mainnet::{
|
||||
HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY, HRP_SAPLING_PAYMENT_ADDRESS,
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "mainnet"))]
|
||||
use zcash_client_backend::constants::testnet::{
|
||||
HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY, HRP_SAPLING_PAYMENT_ADDRESS,
|
||||
};
|
||||
|
||||
pub mod error;
|
||||
pub mod init;
|
||||
pub mod query;
|
||||
@@ -33,6 +46,11 @@ pub mod scan;
|
||||
pub mod transact;
|
||||
|
||||
const ANCHOR_OFFSET: u32 = 10;
|
||||
|
||||
#[cfg(feature = "mainnet")]
|
||||
const SAPLING_ACTIVATION_HEIGHT: i32 = 419_200;
|
||||
|
||||
#[cfg(not(feature = "mainnet"))]
|
||||
const SAPLING_ACTIVATION_HEIGHT: i32 = 280_000;
|
||||
|
||||
fn address_from_extfvk(extfvk: &ExtendedFullViewingKey) -> String {
|
||||
|
||||
@@ -5,7 +5,6 @@ use protobuf::parse_from_bytes;
|
||||
use rusqlite::{types::ToSql, Connection, NO_PARAMS};
|
||||
use std::path::Path;
|
||||
use zcash_client_backend::{
|
||||
constants::testnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
|
||||
encoding::decode_extended_full_viewing_key, proto::compact_formats::CompactBlock,
|
||||
welding_rig::scan_block,
|
||||
};
|
||||
@@ -17,7 +16,7 @@ use zcash_primitives::{
|
||||
|
||||
use crate::{
|
||||
error::{Error, ErrorKind},
|
||||
SAPLING_ACTIVATION_HEIGHT,
|
||||
HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY, SAPLING_ACTIVATION_HEIGHT,
|
||||
};
|
||||
|
||||
struct CompactBlockRow {
|
||||
|
||||
@@ -4,10 +4,7 @@ use ff::{PrimeField, PrimeFieldRepr};
|
||||
use pairing::bls12_381::Bls12;
|
||||
use rusqlite::{types::ToSql, Connection, NO_PARAMS};
|
||||
use std::path::Path;
|
||||
use zcash_client_backend::{
|
||||
constants::testnet::{HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY, HRP_SAPLING_PAYMENT_ADDRESS},
|
||||
encoding::{encode_extended_full_viewing_key, encode_payment_address},
|
||||
};
|
||||
use zcash_client_backend::encoding::{encode_extended_full_viewing_key, encode_payment_address};
|
||||
use zcash_primitives::{
|
||||
jubjub::fs::{Fs, FsRepr},
|
||||
merkle_tree::IncrementalWitness,
|
||||
@@ -25,7 +22,8 @@ use zcash_primitives::{
|
||||
|
||||
use crate::{
|
||||
error::{Error, ErrorKind},
|
||||
get_target_and_anchor_heights,
|
||||
get_target_and_anchor_heights, HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
|
||||
HRP_SAPLING_PAYMENT_ADDRESS,
|
||||
};
|
||||
|
||||
struct SelectedNoteRow {
|
||||
|
||||
Reference in New Issue
Block a user