Renames to use lower-case abbreviations (matching Rust convention)
As of our MSRV bump to 1.51.0, we get lints for this.
This commit is contained in:
parent
6fa90197fe
commit
636845d0f9
|
@ -8,6 +8,10 @@ and this library adheres to Rust's notion of
|
|||
## [Unreleased]
|
||||
### Changed
|
||||
- MSRV is now 1.51.0.
|
||||
- Renamed the following in `zcash_client_backend::data_api` to use lower-case
|
||||
abbreviations (matching Rust naming conventions):
|
||||
- `error::Error::InvalidExtSK` to `Error::InvalidExtSk`
|
||||
- `testing::MockWalletDB` to `testing::MockWalletDb`
|
||||
|
||||
## [0.5.0] - 2021-03-26
|
||||
### Added
|
||||
|
|
|
@ -309,9 +309,9 @@ pub mod testing {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct MockWalletDB {}
|
||||
pub struct MockWalletDb {}
|
||||
|
||||
impl WalletRead for MockWalletDB {
|
||||
impl WalletRead for MockWalletDb {
|
||||
type Error = Error<u32>;
|
||||
type NoteRef = u32;
|
||||
type TxRef = TxId;
|
||||
|
@ -398,7 +398,7 @@ pub mod testing {
|
|||
}
|
||||
}
|
||||
|
||||
impl WalletWrite for MockWalletDB {
|
||||
impl WalletWrite for MockWalletDb {
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn advance_by_block(
|
||||
&mut self,
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
//! };
|
||||
//!
|
||||
//! use zcash_client_sqlite::{
|
||||
//! BlockDB,
|
||||
//! WalletDB,
|
||||
//! BlockDb,
|
||||
//! WalletDb,
|
||||
//! error::SqliteClientError,
|
||||
//! wallet::{rewind_to_height},
|
||||
//! wallet::init::{init_wallet_db},
|
||||
|
@ -37,9 +37,9 @@
|
|||
//! # fn test() -> Result<(), SqliteClientError> {
|
||||
//! let network = Network::TestNetwork;
|
||||
//! let cache_file = NamedTempFile::new()?;
|
||||
//! let db_cache = BlockDB::for_path(cache_file)?;
|
||||
//! let db_cache = BlockDb::for_path(cache_file)?;
|
||||
//! let db_file = NamedTempFile::new()?;
|
||||
//! let db_read = WalletDB::for_path(db_file, network)?;
|
||||
//! let db_read = WalletDb::for_path(db_file, network)?;
|
||||
//! init_wallet_db(&db_read)?;
|
||||
//!
|
||||
//! let mut db_data = db_read.get_update_ops()?;
|
||||
|
@ -211,8 +211,8 @@ where
|
|||
/// data_api::chain::scan_cached_blocks,
|
||||
/// };
|
||||
/// use zcash_client_sqlite::{
|
||||
/// BlockDB,
|
||||
/// WalletDB,
|
||||
/// BlockDb,
|
||||
/// WalletDb,
|
||||
/// error::SqliteClientError,
|
||||
/// wallet::init::init_wallet_db,
|
||||
/// };
|
||||
|
@ -225,10 +225,10 @@ where
|
|||
/// #
|
||||
/// # fn test() -> Result<(), SqliteClientError> {
|
||||
/// let cache_file = NamedTempFile::new().unwrap();
|
||||
/// let cache = BlockDB::for_path(cache_file).unwrap();
|
||||
/// let cache = BlockDb::for_path(cache_file).unwrap();
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db_read = WalletDB::for_path(data_file, Network::TestNetwork)?;
|
||||
/// let db_read = WalletDb::for_path(data_file, Network::TestNetwork)?;
|
||||
/// init_wallet_db(&db_read)?;
|
||||
///
|
||||
/// let mut data = db_read.get_update_ops()?;
|
||||
|
|
|
@ -31,7 +31,7 @@ pub enum Error<NoteId> {
|
|||
InvalidChain(BlockHeight, ChainInvalid),
|
||||
|
||||
/// A provided extsk is not associated with the specified account.
|
||||
InvalidExtSK(AccountId),
|
||||
InvalidExtSk(AccountId),
|
||||
|
||||
/// The root of an output's witness tree in a newly arrived transaction does
|
||||
/// not correspond to root of the stored commitment tree at the recorded height.
|
||||
|
@ -80,7 +80,7 @@ impl<N: fmt::Display> fmt::Display for Error<N> {
|
|||
Error::InvalidChain(upper_bound, cause) => {
|
||||
write!(f, "Invalid chain (upper bound: {}): {:?}", u32::from(*upper_bound), cause)
|
||||
}
|
||||
Error::InvalidExtSK(account) => {
|
||||
Error::InvalidExtSk(account) => {
|
||||
write!(f, "Incorrect ExtendedSpendingKey for account {}", account.0)
|
||||
}
|
||||
Error::InvalidNewWitnessAnchor(output, txid, last_height, anchor) => write!(
|
||||
|
|
|
@ -103,7 +103,7 @@ where
|
|||
/// wallet::{AccountId, OvkPolicy},
|
||||
/// };
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// error::SqliteClientError,
|
||||
/// wallet::init::init_wallet_db,
|
||||
/// };
|
||||
|
@ -127,7 +127,7 @@ where
|
|||
/// let to = extsk.default_address().unwrap().1.into();
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db_read = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db_read = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// init_wallet_db(&db_read)?;
|
||||
/// let mut db = db_read.get_update_ops()?;
|
||||
///
|
||||
|
@ -168,7 +168,7 @@ where
|
|||
// ExtendedFullViewingKey for the account we are spending from.
|
||||
let extfvk = ExtendedFullViewingKey::from(extsk);
|
||||
if !wallet_db.is_valid_account_extfvk(account, &extfvk)? {
|
||||
return Err(E::from(Error::InvalidExtSK(account)));
|
||||
return Err(E::from(Error::InvalidExtSk(account)));
|
||||
}
|
||||
|
||||
// Apply the outgoing viewing key policy.
|
||||
|
|
|
@ -8,6 +8,12 @@ and this library adheres to Rust's notion of
|
|||
## [Unreleased]
|
||||
### Changed
|
||||
- MSRV is now 1.51.0.
|
||||
- Renamed the following to use lower-case abbreviations (matching Rust
|
||||
naming conventions):
|
||||
- `zcash_client_sqlite::BlockDB` to `BlockDb`
|
||||
- `zcash_client_sqlite::WalletDB` to `WalletDb`
|
||||
- `zcash_client_sqlite::error::SqliteClientError::IncorrectHRPExtFVK` to
|
||||
`IncorrectHrpExtFvk`.
|
||||
|
||||
## [0.3.0] - 2021-03-26
|
||||
This release contains a major refactor of the APIs to leverage the new Data
|
||||
|
|
|
@ -7,7 +7,7 @@ use zcash_primitives::consensus::BlockHeight;
|
|||
|
||||
use zcash_client_backend::{data_api::error::Error, proto::compact_formats::CompactBlock};
|
||||
|
||||
use crate::{error::SqliteClientError, BlockDB};
|
||||
use crate::{error::SqliteClientError, BlockDb};
|
||||
|
||||
pub mod init;
|
||||
|
||||
|
@ -23,7 +23,7 @@ struct CompactBlockRow {
|
|||
/// value provided is `None`, all blocks are traversed up to the
|
||||
/// maximum height.
|
||||
pub fn with_blocks<F>(
|
||||
cache: &BlockDB,
|
||||
cache: &BlockDb,
|
||||
from_height: BlockHeight,
|
||||
limit: Option<u32>,
|
||||
mut with_row: F,
|
||||
|
@ -92,17 +92,17 @@ mod tests {
|
|||
init::{init_accounts_table, init_wallet_db},
|
||||
rewind_to_height,
|
||||
},
|
||||
AccountId, BlockDB, NoteId, WalletDB,
|
||||
AccountId, BlockDb, NoteId, WalletDb,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn valid_chain_states() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -179,11 +179,11 @@ mod tests {
|
|||
#[test]
|
||||
fn invalid_chain_cache_disconnected() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -251,11 +251,11 @@ mod tests {
|
|||
#[test]
|
||||
fn invalid_chain_cache_reorg() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -323,11 +323,11 @@ mod tests {
|
|||
#[test]
|
||||
fn data_db_rewinding() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -382,11 +382,11 @@ mod tests {
|
|||
#[test]
|
||||
fn scan_cached_blocks_requires_sequential_blocks() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -443,11 +443,11 @@ mod tests {
|
|||
#[test]
|
||||
fn scan_cached_blocks_finds_received_notes() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -491,11 +491,11 @@ mod tests {
|
|||
#[test]
|
||||
fn scan_cached_blocks_finds_change_notes() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
let db_cache = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use rusqlite::NO_PARAMS;
|
||||
|
||||
use crate::BlockDB;
|
||||
use crate::BlockDb;
|
||||
|
||||
/// Sets up the internal structure of the cache database.
|
||||
///
|
||||
|
@ -11,15 +11,15 @@ use crate::BlockDB;
|
|||
/// ```
|
||||
/// use tempfile::NamedTempFile;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// BlockDB,
|
||||
/// BlockDb,
|
||||
/// chain::init::init_cache_database,
|
||||
/// };
|
||||
///
|
||||
/// let cache_file = NamedTempFile::new().unwrap();
|
||||
/// let db = BlockDB::for_path(cache_file.path()).unwrap();
|
||||
/// let db = BlockDb::for_path(cache_file.path()).unwrap();
|
||||
/// init_cache_database(&db).unwrap();
|
||||
/// ```
|
||||
pub fn init_cache_database(db_cache: &BlockDB) -> Result<(), rusqlite::Error> {
|
||||
pub fn init_cache_database(db_cache: &BlockDb) -> Result<(), rusqlite::Error> {
|
||||
db_cache.0.execute(
|
||||
"CREATE TABLE IF NOT EXISTS compactblocks (
|
||||
height INTEGER PRIMARY KEY,
|
||||
|
|
|
@ -14,7 +14,7 @@ pub enum SqliteClientError {
|
|||
CorruptedData(String),
|
||||
|
||||
/// Decoding of the extended full viewing key has failed (for the specified network)
|
||||
IncorrectHRPExtFVK,
|
||||
IncorrectHrpExtFvk,
|
||||
|
||||
/// The rcm value for a note cannot be decoded to a valid JubJub point.
|
||||
InvalidNote,
|
||||
|
@ -63,7 +63,7 @@ impl fmt::Display for SqliteClientError {
|
|||
SqliteClientError::CorruptedData(reason) => {
|
||||
write!(f, "Data DB is corrupted: {}", reason)
|
||||
}
|
||||
SqliteClientError::IncorrectHRPExtFVK => write!(f, "Incorrect HRP for extfvk"),
|
||||
SqliteClientError::IncorrectHrpExtFvk => write!(f, "Incorrect HRP for extfvk"),
|
||||
SqliteClientError::InvalidNote => write!(f, "Invalid note"),
|
||||
SqliteClientError::InvalidNoteId => write!(f, "The note ID associated with an inserted witness must correspond to a received note."),
|
||||
SqliteClientError::Bech32(e) => write!(f, "{}", e),
|
||||
|
|
|
@ -81,15 +81,15 @@ impl fmt::Display for NoteId {
|
|||
}
|
||||
|
||||
/// A wrapper for the SQLite connection to the wallet database.
|
||||
pub struct WalletDB<P> {
|
||||
pub struct WalletDb<P> {
|
||||
conn: Connection,
|
||||
params: P,
|
||||
}
|
||||
|
||||
impl<P: consensus::Parameters> WalletDB<P> {
|
||||
impl<P: consensus::Parameters> WalletDb<P> {
|
||||
/// Construct a connection to the wallet database stored at the specified path.
|
||||
pub fn for_path<F: AsRef<Path>>(path: F, params: P) -> Result<Self, rusqlite::Error> {
|
||||
Connection::open(path).map(move |conn| WalletDB { conn, params })
|
||||
Connection::open(path).map(move |conn| WalletDb { conn, params })
|
||||
}
|
||||
|
||||
/// Given a wallet database connection, obtain a handle for the write operations
|
||||
|
@ -170,7 +170,7 @@ impl<P: consensus::Parameters> WalletDB<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: consensus::Parameters> WalletRead for WalletDB<P> {
|
||||
impl<P: consensus::Parameters> WalletRead for WalletDb<P> {
|
||||
type Error = SqliteClientError;
|
||||
type NoteRef = NoteId;
|
||||
type TxRef = i64;
|
||||
|
@ -265,7 +265,7 @@ impl<P: consensus::Parameters> WalletRead for WalletDB<P> {
|
|||
///
|
||||
/// [`WalletWrite`]: zcash_client_backend::data_api::WalletWrite
|
||||
pub struct DataConnStmtCache<'a, P> {
|
||||
wallet_db: &'a WalletDB<P>,
|
||||
wallet_db: &'a WalletDb<P>,
|
||||
stmt_insert_block: Statement<'a>,
|
||||
|
||||
stmt_insert_tx_meta: Statement<'a>,
|
||||
|
@ -514,16 +514,16 @@ impl<'a, P: consensus::Parameters> WalletWrite for DataConnStmtCache<'a, P> {
|
|||
}
|
||||
|
||||
/// A wrapper for the SQLite connection to the block cache database.
|
||||
pub struct BlockDB(Connection);
|
||||
pub struct BlockDb(Connection);
|
||||
|
||||
impl BlockDB {
|
||||
impl BlockDb {
|
||||
/// Opens a connection to the wallet database stored at the specified path.
|
||||
pub fn for_path<P: AsRef<Path>>(path: P) -> Result<Self, rusqlite::Error> {
|
||||
Connection::open(path).map(BlockDB)
|
||||
Connection::open(path).map(BlockDb)
|
||||
}
|
||||
}
|
||||
|
||||
impl BlockSource for BlockDB {
|
||||
impl BlockSource for BlockDb {
|
||||
type Error = SqliteClientError;
|
||||
|
||||
fn with_blocks<F>(
|
||||
|
@ -569,7 +569,7 @@ mod tests {
|
|||
zip32::ExtendedFullViewingKey,
|
||||
};
|
||||
|
||||
use super::BlockDB;
|
||||
use super::BlockDb;
|
||||
|
||||
#[cfg(feature = "mainnet")]
|
||||
pub(crate) fn network() -> Network {
|
||||
|
@ -730,7 +730,7 @@ mod tests {
|
|||
}
|
||||
|
||||
/// Insert a fake CompactBlock into the cache DB.
|
||||
pub(crate) fn insert_into_cache(db_cache: &BlockDB, cb: &CompactBlock) {
|
||||
pub(crate) fn insert_into_cache(db_cache: &BlockDb, cb: &CompactBlock) {
|
||||
let cb_bytes = cb.write_to_bytes().unwrap();
|
||||
db_cache
|
||||
.0
|
||||
|
|
|
@ -33,7 +33,7 @@ use zcash_client_backend::{
|
|||
DecryptedOutput,
|
||||
};
|
||||
|
||||
use crate::{error::SqliteClientError, DataConnStmtCache, NoteId, WalletDB};
|
||||
use crate::{error::SqliteClientError, DataConnStmtCache, NoteId, WalletDb};
|
||||
|
||||
pub mod init;
|
||||
pub mod transact;
|
||||
|
@ -109,16 +109,16 @@ impl ShieldedOutput for DecryptedOutput {
|
|||
/// };
|
||||
/// use zcash_client_backend::wallet::AccountId;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_address,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let addr = get_address(&db, AccountId(0));
|
||||
/// ```
|
||||
pub fn get_address<P: consensus::Parameters>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
account: AccountId,
|
||||
) -> Result<Option<PaymentAddress>, SqliteClientError> {
|
||||
let addr: String = wdb.conn.query_row(
|
||||
|
@ -136,7 +136,7 @@ pub fn get_address<P: consensus::Parameters>(
|
|||
///
|
||||
/// [`ExtendedFullViewingKey`]: zcash_primitives::zip32::ExtendedFullViewingKey
|
||||
pub fn get_extended_full_viewing_keys<P: consensus::Parameters>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
) -> Result<HashMap<AccountId, ExtendedFullViewingKey>, SqliteClientError> {
|
||||
// Fetch the ExtendedFullViewingKeys we are tracking
|
||||
let mut stmt_fetch_accounts = wdb
|
||||
|
@ -152,7 +152,7 @@ pub fn get_extended_full_viewing_keys<P: consensus::Parameters>(
|
|||
&extfvk,
|
||||
)
|
||||
.map_err(SqliteClientError::Bech32)
|
||||
.and_then(|k| k.ok_or(SqliteClientError::IncorrectHRPExtFVK))
|
||||
.and_then(|k| k.ok_or(SqliteClientError::IncorrectHrpExtFvk))
|
||||
})?;
|
||||
|
||||
Ok((acct, extfvk))
|
||||
|
@ -173,7 +173,7 @@ pub fn get_extended_full_viewing_keys<P: consensus::Parameters>(
|
|||
///
|
||||
/// [`ExtendedFullViewingKey`]: zcash_primitives::zip32::ExtendedFullViewingKey
|
||||
pub fn is_valid_account_extfvk<P: consensus::Parameters>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
account: AccountId,
|
||||
extfvk: &ExtendedFullViewingKey,
|
||||
) -> Result<bool, SqliteClientError> {
|
||||
|
@ -205,15 +205,15 @@ pub fn is_valid_account_extfvk<P: consensus::Parameters>(
|
|||
/// use zcash_primitives::consensus::Network;
|
||||
/// use zcash_client_backend::wallet::AccountId;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_balance,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let addr = get_balance(&db, AccountId(0));
|
||||
/// ```
|
||||
pub fn get_balance<P>(wdb: &WalletDB<P>, account: AccountId) -> Result<Amount, SqliteClientError> {
|
||||
pub fn get_balance<P>(wdb: &WalletDb<P>, account: AccountId) -> Result<Amount, SqliteClientError> {
|
||||
let balance = wdb.conn.query_row(
|
||||
"SELECT SUM(value) FROM received_notes
|
||||
INNER JOIN transactions ON transactions.id_tx = received_notes.tx
|
||||
|
@ -241,16 +241,16 @@ pub fn get_balance<P>(wdb: &WalletDB<P>, account: AccountId) -> Result<Amount, S
|
|||
/// use zcash_primitives::consensus::{BlockHeight, Network};
|
||||
/// use zcash_client_backend::wallet::AccountId;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_balance_at,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let addr = get_balance_at(&db, AccountId(0), BlockHeight::from_u32(0));
|
||||
/// ```
|
||||
pub fn get_balance_at<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
account: AccountId,
|
||||
anchor_height: BlockHeight,
|
||||
) -> Result<Amount, SqliteClientError> {
|
||||
|
@ -282,15 +282,15 @@ pub fn get_balance_at<P>(
|
|||
/// use zcash_primitives::consensus::Network;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// NoteId,
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_received_memo,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let memo = get_received_memo(&db, 27);
|
||||
/// ```
|
||||
pub fn get_received_memo<P>(wdb: &WalletDB<P>, id_note: i64) -> Result<Memo, SqliteClientError> {
|
||||
pub fn get_received_memo<P>(wdb: &WalletDb<P>, id_note: i64) -> Result<Memo, SqliteClientError> {
|
||||
let memo_bytes: Vec<_> = wdb.conn.query_row(
|
||||
"SELECT memo FROM received_notes
|
||||
WHERE id_note = ?",
|
||||
|
@ -315,15 +315,15 @@ pub fn get_received_memo<P>(wdb: &WalletDB<P>, id_note: i64) -> Result<Memo, Sql
|
|||
/// use zcash_primitives::consensus::Network;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// NoteId,
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_sent_memo,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let memo = get_sent_memo(&db, 12);
|
||||
/// ```
|
||||
pub fn get_sent_memo<P>(wdb: &WalletDB<P>, id_note: i64) -> Result<Memo, SqliteClientError> {
|
||||
pub fn get_sent_memo<P>(wdb: &WalletDb<P>, id_note: i64) -> Result<Memo, SqliteClientError> {
|
||||
let memo_bytes: Vec<_> = wdb.conn.query_row(
|
||||
"SELECT memo FROM sent_notes
|
||||
WHERE id_note = ?",
|
||||
|
@ -344,16 +344,16 @@ pub fn get_sent_memo<P>(wdb: &WalletDB<P>, id_note: i64) -> Result<Memo, SqliteC
|
|||
/// use tempfile::NamedTempFile;
|
||||
/// use zcash_primitives::consensus::Network;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::block_height_extrema,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let bounds = block_height_extrema(&db);
|
||||
/// ```
|
||||
pub fn block_height_extrema<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
) -> Result<Option<(BlockHeight, BlockHeight)>, rusqlite::Error> {
|
||||
wdb.conn
|
||||
.query_row(
|
||||
|
@ -383,16 +383,16 @@ pub fn block_height_extrema<P>(
|
|||
/// use zcash_primitives::consensus::Network;
|
||||
/// use zcash_primitives::transaction::TxId;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_tx_height,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let height = get_tx_height(&db, TxId([0u8; 32]));
|
||||
/// ```
|
||||
pub fn get_tx_height<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
txid: TxId,
|
||||
) -> Result<Option<BlockHeight>, rusqlite::Error> {
|
||||
wdb.conn
|
||||
|
@ -413,16 +413,16 @@ pub fn get_tx_height<P>(
|
|||
/// use tempfile::NamedTempFile;
|
||||
/// use zcash_primitives::consensus::{H0, Network};
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_block_hash,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let hash = get_block_hash(&db, H0);
|
||||
/// ```
|
||||
pub fn get_block_hash<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
block_height: BlockHeight,
|
||||
) -> Result<Option<BlockHash>, rusqlite::Error> {
|
||||
wdb.conn
|
||||
|
@ -444,7 +444,7 @@ pub fn get_block_hash<P>(
|
|||
///
|
||||
/// This should only be executed inside a transactional context.
|
||||
pub fn rewind_to_height<P: consensus::Parameters>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
block_height: BlockHeight,
|
||||
) -> Result<(), SqliteClientError> {
|
||||
let sapling_activation_height = wdb
|
||||
|
@ -496,16 +496,16 @@ pub fn rewind_to_height<P: consensus::Parameters>(
|
|||
/// use tempfile::NamedTempFile;
|
||||
/// use zcash_primitives::consensus::{Network, H0};
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_commitment_tree,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let tree = get_commitment_tree(&db, H0);
|
||||
/// ```
|
||||
pub fn get_commitment_tree<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
block_height: BlockHeight,
|
||||
) -> Result<Option<CommitmentTree<Node>>, SqliteClientError> {
|
||||
wdb.conn
|
||||
|
@ -536,16 +536,16 @@ pub fn get_commitment_tree<P>(
|
|||
/// use tempfile::NamedTempFile;
|
||||
/// use zcash_primitives::consensus::{Network, H0};
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::get_witnesses,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file, Network::TestNetwork).unwrap();
|
||||
/// let witnesses = get_witnesses(&db, H0);
|
||||
/// ```
|
||||
pub fn get_witnesses<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
block_height: BlockHeight,
|
||||
) -> Result<Vec<(NoteId, IncrementalWitness<Node>)>, SqliteClientError> {
|
||||
let mut stmt_fetch_witnesses = wdb
|
||||
|
@ -568,7 +568,7 @@ pub fn get_witnesses<P>(
|
|||
/// that have not yet been confirmed as a consequence of the spending
|
||||
/// transaction being included in a block.
|
||||
pub fn get_nullifiers<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
) -> Result<Vec<(AccountId, Nullifier)>, SqliteClientError> {
|
||||
// Get the nullifiers for the notes we are tracking
|
||||
let mut stmt_fetch_nullifiers = wdb.conn.prepare(
|
||||
|
@ -862,7 +862,7 @@ mod tests {
|
|||
use crate::{
|
||||
tests,
|
||||
wallet::init::{init_accounts_table, init_wallet_db},
|
||||
AccountId, WalletDB,
|
||||
AccountId, WalletDb,
|
||||
};
|
||||
|
||||
use super::{get_address, get_balance};
|
||||
|
@ -870,7 +870,7 @@ mod tests {
|
|||
#[test]
|
||||
fn empty_database_has_no_balance() {
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
|
|
@ -10,7 +10,7 @@ use zcash_primitives::{
|
|||
|
||||
use zcash_client_backend::encoding::encode_extended_full_viewing_key;
|
||||
|
||||
use crate::{address_from_extfvk, error::SqliteClientError, WalletDB};
|
||||
use crate::{address_from_extfvk, error::SqliteClientError, WalletDb};
|
||||
|
||||
/// Sets up the internal structure of the data database.
|
||||
///
|
||||
|
@ -20,15 +20,15 @@ use crate::{address_from_extfvk, error::SqliteClientError, WalletDB};
|
|||
/// use tempfile::NamedTempFile;
|
||||
/// use zcash_primitives::consensus::Network;
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::init::init_wallet_db,
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file.path(), Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file.path(), Network::TestNetwork).unwrap();
|
||||
/// init_wallet_db(&db).unwrap();
|
||||
/// ```
|
||||
pub fn init_wallet_db<P>(wdb: &WalletDB<P>) -> Result<(), rusqlite::Error> {
|
||||
pub fn init_wallet_db<P>(wdb: &WalletDb<P>) -> Result<(), rusqlite::Error> {
|
||||
wdb.conn.execute(
|
||||
"CREATE TABLE IF NOT EXISTS accounts (
|
||||
account INTEGER PRIMARY KEY,
|
||||
|
@ -127,12 +127,12 @@ pub fn init_wallet_db<P>(wdb: &WalletDB<P>) -> Result<(), rusqlite::Error> {
|
|||
/// };
|
||||
///
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::init::{init_accounts_table, init_wallet_db}
|
||||
/// };
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db_data = WalletDB::for_path(data_file.path(), Network::TestNetwork).unwrap();
|
||||
/// let db_data = WalletDb::for_path(data_file.path(), Network::TestNetwork).unwrap();
|
||||
/// init_wallet_db(&db_data).unwrap();
|
||||
///
|
||||
/// let extsk = ExtendedSpendingKey::master(&[]);
|
||||
|
@ -144,7 +144,7 @@ pub fn init_wallet_db<P>(wdb: &WalletDB<P>) -> Result<(), rusqlite::Error> {
|
|||
/// [`scan_cached_blocks`]: zcash_client_backend::data_api::chain::scan_cached_blocks
|
||||
/// [`create_spend_to_address`]: zcash_client_backend::data_api::wallet::create_spend_to_address
|
||||
pub fn init_accounts_table<P: consensus::Parameters>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
extfvks: &[ExtendedFullViewingKey],
|
||||
) -> Result<(), SqliteClientError> {
|
||||
let mut empty_check = wdb.conn.prepare("SELECT * FROM accounts LIMIT 1")?;
|
||||
|
@ -191,7 +191,7 @@ pub fn init_accounts_table<P: consensus::Parameters>(
|
|||
/// consensus::{BlockHeight, Network},
|
||||
/// };
|
||||
/// use zcash_client_sqlite::{
|
||||
/// WalletDB,
|
||||
/// WalletDb,
|
||||
/// wallet::init::init_blocks_table,
|
||||
/// };
|
||||
///
|
||||
|
@ -206,11 +206,11 @@ pub fn init_accounts_table<P: consensus::Parameters>(
|
|||
/// let sapling_tree = &[];
|
||||
///
|
||||
/// let data_file = NamedTempFile::new().unwrap();
|
||||
/// let db = WalletDB::for_path(data_file.path(), Network::TestNetwork).unwrap();
|
||||
/// let db = WalletDb::for_path(data_file.path(), Network::TestNetwork).unwrap();
|
||||
/// init_blocks_table(&db, height, hash, time, sapling_tree);
|
||||
/// ```
|
||||
pub fn init_blocks_table<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
height: BlockHeight,
|
||||
hash: BlockHash,
|
||||
time: u32,
|
||||
|
@ -245,14 +245,14 @@ mod tests {
|
|||
zip32::{ExtendedFullViewingKey, ExtendedSpendingKey},
|
||||
};
|
||||
|
||||
use crate::{tests, wallet::get_address, AccountId, WalletDB};
|
||||
use crate::{tests, wallet::get_address, AccountId, WalletDb};
|
||||
|
||||
use super::{init_accounts_table, init_blocks_table, init_wallet_db};
|
||||
|
||||
#[test]
|
||||
fn init_accounts_table_only_works_once() {
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// We can call the function as many times as we want with no data
|
||||
|
@ -273,7 +273,7 @@ mod tests {
|
|||
#[test]
|
||||
fn init_blocks_table_only_works_once() {
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// First call with data should initialise the blocks table
|
||||
|
@ -300,7 +300,7 @@ mod tests {
|
|||
#[test]
|
||||
fn init_accounts_table_stores_correct_address() {
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
|
|
@ -14,7 +14,7 @@ use zcash_primitives::{
|
|||
|
||||
use zcash_client_backend::wallet::{AccountId, SpendableNote};
|
||||
|
||||
use crate::{error::SqliteClientError, WalletDB};
|
||||
use crate::{error::SqliteClientError, WalletDb};
|
||||
|
||||
fn to_spendable_note(row: &Row) -> Result<SpendableNote, SqliteClientError> {
|
||||
let diversifier = {
|
||||
|
@ -60,7 +60,7 @@ fn to_spendable_note(row: &Row) -> Result<SpendableNote, SqliteClientError> {
|
|||
}
|
||||
|
||||
pub fn get_spendable_notes<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
account: AccountId,
|
||||
anchor_height: BlockHeight,
|
||||
) -> Result<Vec<SpendableNote>, SqliteClientError> {
|
||||
|
@ -88,7 +88,7 @@ pub fn get_spendable_notes<P>(
|
|||
}
|
||||
|
||||
pub fn select_spendable_notes<P>(
|
||||
wdb: &WalletDB<P>,
|
||||
wdb: &WalletDb<P>,
|
||||
account: AccountId,
|
||||
target_value: Amount,
|
||||
anchor_height: BlockHeight,
|
||||
|
@ -175,7 +175,7 @@ mod tests {
|
|||
get_balance, get_balance_at,
|
||||
init::{init_accounts_table, init_blocks_table, init_wallet_db},
|
||||
},
|
||||
AccountId, BlockDB, DataConnStmtCache, WalletDB,
|
||||
AccountId, BlockDb, DataConnStmtCache, WalletDb,
|
||||
};
|
||||
|
||||
fn test_prover() -> impl TxProver {
|
||||
|
@ -190,7 +190,7 @@ mod tests {
|
|||
#[test]
|
||||
fn create_to_address_fails_on_incorrect_extsk() {
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add two accounts to the wallet
|
||||
|
@ -239,7 +239,7 @@ mod tests {
|
|||
#[test]
|
||||
fn create_to_address_fails_with_no_blocks() {
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -269,7 +269,7 @@ mod tests {
|
|||
#[test]
|
||||
fn create_to_address_fails_on_insufficient_balance() {
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
init_blocks_table(
|
||||
&db_data,
|
||||
|
@ -313,11 +313,11 @@ mod tests {
|
|||
#[test]
|
||||
fn create_to_address_fails_on_unverified_notes() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
|
||||
let db_cache = BlockDb(Connection::open(cache_file.path()).unwrap());
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -440,11 +440,11 @@ mod tests {
|
|||
#[test]
|
||||
fn create_to_address_fails_on_locked_notes() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
|
||||
let db_cache = BlockDb(Connection::open(cache_file.path()).unwrap());
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -561,11 +561,11 @@ mod tests {
|
|||
fn ovk_policy_prevents_recovery_from_chain() {
|
||||
let network = tests::network();
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
|
||||
let db_cache = BlockDb(Connection::open(cache_file.path()).unwrap());
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), network).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), network).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
@ -670,11 +670,11 @@ mod tests {
|
|||
#[test]
|
||||
fn create_to_address_succeeds_to_t_addr_zero_change() {
|
||||
let cache_file = NamedTempFile::new().unwrap();
|
||||
let db_cache = BlockDB(Connection::open(cache_file.path()).unwrap());
|
||||
let db_cache = BlockDb(Connection::open(cache_file.path()).unwrap());
|
||||
init_cache_database(&db_cache).unwrap();
|
||||
|
||||
let data_file = NamedTempFile::new().unwrap();
|
||||
let db_data = WalletDB::for_path(data_file.path(), tests::network()).unwrap();
|
||||
let db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
|
||||
init_wallet_db(&db_data).unwrap();
|
||||
|
||||
// Add an account to the wallet
|
||||
|
|
|
@ -17,6 +17,10 @@ and this library adheres to Rust's notion of
|
|||
- `zcash_primitives::prover`
|
||||
- `zcash_primitives::redjubjub`
|
||||
- `zcash_primitives::util::{hash_to_scalar, generate_random_rseed}`
|
||||
- Renamed the following in `zcash_primitives::transaction::components` to use
|
||||
lower-case abbreviations (matching Rust naming conventions):
|
||||
- `JSDescription` to `JsDescription`
|
||||
- `SproutProof::PHGR` to `SproutProof::Phgr`
|
||||
|
||||
## [0.5.0] - 2021-03-26
|
||||
### Added
|
||||
|
|
|
@ -8,7 +8,7 @@ pub mod tze;
|
|||
pub use self::{
|
||||
amount::Amount,
|
||||
sapling::{OutputDescription, SpendDescription},
|
||||
sprout::JSDescription,
|
||||
sprout::JsDescription,
|
||||
transparent::{OutPoint, TxIn, TxOut},
|
||||
};
|
||||
|
||||
|
|
|
@ -13,20 +13,20 @@ const ZC_NUM_JS_OUTPUTS: usize = 2;
|
|||
#[derive(Clone)]
|
||||
pub(crate) enum SproutProof {
|
||||
Groth([u8; GROTH_PROOF_SIZE]),
|
||||
PHGR([u8; PHGR_PROOF_SIZE]),
|
||||
Phgr([u8; PHGR_PROOF_SIZE]),
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for SproutProof {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||
match self {
|
||||
SproutProof::Groth(_) => write!(f, "SproutProof::Groth"),
|
||||
SproutProof::PHGR(_) => write!(f, "SproutProof::PHGR"),
|
||||
SproutProof::Phgr(_) => write!(f, "SproutProof::PHGR"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct JSDescription {
|
||||
pub struct JsDescription {
|
||||
pub(crate) vpub_old: Amount,
|
||||
pub(crate) vpub_new: Amount,
|
||||
pub(crate) anchor: [u8; 32],
|
||||
|
@ -39,7 +39,7 @@ pub struct JSDescription {
|
|||
pub(crate) ciphertexts: [[u8; 601]; ZC_NUM_JS_OUTPUTS],
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for JSDescription {
|
||||
impl std::fmt::Debug for JsDescription {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||
write!(
|
||||
f,
|
||||
|
@ -63,7 +63,7 @@ impl std::fmt::Debug for JSDescription {
|
|||
}
|
||||
}
|
||||
|
||||
impl JSDescription {
|
||||
impl JsDescription {
|
||||
pub fn read<R: Read>(mut reader: R, use_groth: bool) -> io::Result<Self> {
|
||||
// Consensus rule (§4.3): Canonical encoding is enforced here
|
||||
let vpub_old = {
|
||||
|
@ -125,7 +125,7 @@ impl JSDescription {
|
|||
// - Proof validity is enforced by JSDescription::Verify() in zcashd
|
||||
let mut proof = [0u8; PHGR_PROOF_SIZE];
|
||||
reader.read_exact(&mut proof)?;
|
||||
SproutProof::PHGR(proof)
|
||||
SproutProof::Phgr(proof)
|
||||
};
|
||||
|
||||
let mut ciphertexts = [[0u8; 601]; ZC_NUM_JS_OUTPUTS];
|
||||
|
@ -134,7 +134,7 @@ impl JSDescription {
|
|||
.map(|ct| reader.read_exact(ct))
|
||||
.collect::<io::Result<()>>()?;
|
||||
|
||||
Ok(JSDescription {
|
||||
Ok(JsDescription {
|
||||
vpub_old,
|
||||
vpub_new,
|
||||
anchor,
|
||||
|
@ -163,7 +163,7 @@ impl JSDescription {
|
|||
|
||||
match &self.proof {
|
||||
SproutProof::Groth(p) => writer.write_all(p)?,
|
||||
SproutProof::PHGR(p) => writer.write_all(p)?,
|
||||
SproutProof::Phgr(p) => writer.write_all(p)?,
|
||||
}
|
||||
|
||||
writer.write_all(&self.ciphertexts[0])?;
|
||||
|
|
|
@ -19,7 +19,7 @@ mod tests;
|
|||
|
||||
pub use self::sighash::{signature_hash, signature_hash_data, SignableInput, SIGHASH_ALL};
|
||||
|
||||
use self::components::{Amount, JSDescription, OutputDescription, SpendDescription, TxIn, TxOut};
|
||||
use self::components::{Amount, JsDescription, OutputDescription, SpendDescription, TxIn, TxOut};
|
||||
|
||||
#[cfg(feature = "zfuture")]
|
||||
use self::components::{TzeIn, TzeOut};
|
||||
|
@ -183,7 +183,7 @@ pub struct TransactionData {
|
|||
pub value_balance: Amount,
|
||||
pub shielded_spends: Vec<SpendDescription>,
|
||||
pub shielded_outputs: Vec<OutputDescription>,
|
||||
pub joinsplits: Vec<JSDescription>,
|
||||
pub joinsplits: Vec<JsDescription>,
|
||||
pub joinsplit_pubkey: Option<[u8; 32]>,
|
||||
pub joinsplit_sig: Option<[u8; 64]>,
|
||||
pub binding_sig: Option<Signature>,
|
||||
|
@ -349,7 +349,7 @@ impl Transaction {
|
|||
|
||||
let (joinsplits, joinsplit_pubkey, joinsplit_sig) = if version.has_sprout() {
|
||||
let jss = Vector::read(&mut reader, |r| {
|
||||
JSDescription::read(r, version.uses_groth_proofs())
|
||||
JsDescription::read(r, version.uses_groth_proofs())
|
||||
})?;
|
||||
let (pubkey, sig) = if !jss.is_empty() {
|
||||
let mut joinsplit_pubkey = [0; 32];
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
|||
};
|
||||
|
||||
use super::{
|
||||
components::{Amount, JSDescription, OutputDescription, SpendDescription, TxIn, TxOut},
|
||||
components::{Amount, JsDescription, OutputDescription, SpendDescription, TxIn, TxOut},
|
||||
Transaction, TransactionData, TxVersion,
|
||||
};
|
||||
|
||||
|
@ -122,7 +122,7 @@ fn single_output_hash(tx_out: &TxOut) -> Blake2bHash {
|
|||
|
||||
fn joinsplits_hash(
|
||||
txversion: TxVersion,
|
||||
joinsplits: &[JSDescription],
|
||||
joinsplits: &[JsDescription],
|
||||
joinsplit_pubkey: &[u8; 32],
|
||||
) -> Blake2bHash {
|
||||
let mut data = Vec::with_capacity(
|
||||
|
|
|
@ -32,9 +32,9 @@ fn derive_child_ovk(parent: &OutgoingViewingKey, i_l: &[u8]) -> OutgoingViewingK
|
|||
// ZIP 32 structures
|
||||
|
||||
/// A Sapling full viewing key fingerprint
|
||||
struct FVKFingerprint([u8; 32]);
|
||||
struct FvkFingerprint([u8; 32]);
|
||||
|
||||
impl From<&FullViewingKey> for FVKFingerprint {
|
||||
impl From<&FullViewingKey> for FvkFingerprint {
|
||||
fn from(fvk: &FullViewingKey) -> Self {
|
||||
let mut h = Blake2bParams::new()
|
||||
.hash_length(32)
|
||||
|
@ -43,25 +43,25 @@ impl From<&FullViewingKey> for FVKFingerprint {
|
|||
h.update(&fvk.to_bytes());
|
||||
let mut fvfp = [0u8; 32];
|
||||
fvfp.copy_from_slice(h.finalize().as_bytes());
|
||||
FVKFingerprint(fvfp)
|
||||
FvkFingerprint(fvfp)
|
||||
}
|
||||
}
|
||||
|
||||
/// A Sapling full viewing key tag
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
struct FVKTag([u8; 4]);
|
||||
struct FvkTag([u8; 4]);
|
||||
|
||||
impl FVKFingerprint {
|
||||
fn tag(&self) -> FVKTag {
|
||||
impl FvkFingerprint {
|
||||
fn tag(&self) -> FvkTag {
|
||||
let mut tag = [0u8; 4];
|
||||
tag.copy_from_slice(&self.0[..4]);
|
||||
FVKTag(tag)
|
||||
FvkTag(tag)
|
||||
}
|
||||
}
|
||||
|
||||
impl FVKTag {
|
||||
impl FvkTag {
|
||||
fn master() -> Self {
|
||||
FVKTag([0u8; 4])
|
||||
FvkTag([0u8; 4])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ impl DiversifierKey {
|
|||
#[derive(Clone)]
|
||||
pub struct ExtendedSpendingKey {
|
||||
depth: u8,
|
||||
parent_fvk_tag: FVKTag,
|
||||
parent_fvk_tag: FvkTag,
|
||||
child_index: ChildIndex,
|
||||
chain_code: ChainCode,
|
||||
pub expsk: ExpandedSpendingKey,
|
||||
|
@ -185,7 +185,7 @@ pub struct ExtendedSpendingKey {
|
|||
#[derive(Clone)]
|
||||
pub struct ExtendedFullViewingKey {
|
||||
depth: u8,
|
||||
parent_fvk_tag: FVKTag,
|
||||
parent_fvk_tag: FvkTag,
|
||||
child_index: ChildIndex,
|
||||
chain_code: ChainCode,
|
||||
pub fvk: FullViewingKey,
|
||||
|
@ -251,7 +251,7 @@ impl ExtendedSpendingKey {
|
|||
|
||||
ExtendedSpendingKey {
|
||||
depth: 0,
|
||||
parent_fvk_tag: FVKTag::master(),
|
||||
parent_fvk_tag: FvkTag::master(),
|
||||
child_index: ChildIndex::master(),
|
||||
chain_code: ChainCode(c_m),
|
||||
expsk: ExpandedSpendingKey::from_spending_key(sk_m),
|
||||
|
@ -272,7 +272,7 @@ impl ExtendedSpendingKey {
|
|||
|
||||
Ok(ExtendedSpendingKey {
|
||||
depth,
|
||||
parent_fvk_tag: FVKTag(tag),
|
||||
parent_fvk_tag: FvkTag(tag),
|
||||
child_index: ChildIndex::from_index(i),
|
||||
chain_code: ChainCode(c),
|
||||
expsk,
|
||||
|
@ -326,7 +326,7 @@ impl ExtendedSpendingKey {
|
|||
|
||||
ExtendedSpendingKey {
|
||||
depth: self.depth + 1,
|
||||
parent_fvk_tag: FVKFingerprint::from(&fvk).tag(),
|
||||
parent_fvk_tag: FvkFingerprint::from(&fvk).tag(),
|
||||
child_index: i,
|
||||
chain_code: ChainCode(c_i),
|
||||
expsk: {
|
||||
|
@ -373,7 +373,7 @@ impl ExtendedFullViewingKey {
|
|||
|
||||
Ok(ExtendedFullViewingKey {
|
||||
depth,
|
||||
parent_fvk_tag: FVKTag(tag),
|
||||
parent_fvk_tag: FvkTag(tag),
|
||||
child_index: ChildIndex::from_index(i),
|
||||
chain_code: ChainCode(c),
|
||||
fvk,
|
||||
|
@ -410,7 +410,7 @@ impl ExtendedFullViewingKey {
|
|||
|
||||
Ok(ExtendedFullViewingKey {
|
||||
depth: self.depth + 1,
|
||||
parent_fvk_tag: FVKFingerprint::from(&self.fvk).tag(),
|
||||
parent_fvk_tag: FvkFingerprint::from(&self.fvk).tag(),
|
||||
child_index: i,
|
||||
chain_code: ChainCode(c_i),
|
||||
fvk: {
|
||||
|
@ -1035,7 +1035,7 @@ mod tests {
|
|||
let mut ser = vec![];
|
||||
xfvk.write(&mut ser).unwrap();
|
||||
assert_eq!(&ser[..], &tv.xfvk[..]);
|
||||
assert_eq!(FVKFingerprint::from(&xfvk.fvk).0, tv.fp);
|
||||
assert_eq!(FvkFingerprint::from(&xfvk.fvk).0, tv.fp);
|
||||
|
||||
// d0
|
||||
let mut di = DiversifierIndex::new();
|
||||
|
|
|
@ -8,6 +8,10 @@ and this library adheres to Rust's notion of
|
|||
## [Unreleased]
|
||||
### Changed
|
||||
- MSRV is now 1.51.0.
|
||||
- Renamed the following in `zcash_proofs::circuit::sprout` to use lower-case
|
||||
abbreviations (matching Rust naming conventions):
|
||||
- `JSInput` to `JsInput`
|
||||
- `JSOutput` to `JsOutput`
|
||||
|
||||
## [0.5.0] - 2021-03-26
|
||||
### Added
|
||||
|
|
|
@ -35,12 +35,12 @@ pub struct JoinSplit {
|
|||
pub vpub_new: Option<u64>,
|
||||
pub h_sig: Option<[u8; 32]>,
|
||||
pub phi: Option<[u8; 32]>,
|
||||
pub inputs: Vec<JSInput>,
|
||||
pub outputs: Vec<JSOutput>,
|
||||
pub inputs: Vec<JsInput>,
|
||||
pub outputs: Vec<JsOutput>,
|
||||
pub rt: Option<[u8; 32]>,
|
||||
}
|
||||
|
||||
pub struct JSInput {
|
||||
pub struct JsInput {
|
||||
pub value: Option<u64>,
|
||||
pub a_sk: Option<SpendingKey>,
|
||||
pub rho: Option<UniqueRandomness>,
|
||||
|
@ -48,7 +48,7 @@ pub struct JSInput {
|
|||
pub auth_path: [Option<([u8; 32], bool)>; TREE_DEPTH],
|
||||
}
|
||||
|
||||
pub struct JSOutput {
|
||||
pub struct JsOutput {
|
||||
pub value: Option<u64>,
|
||||
pub a_pk: Option<PayingKey>,
|
||||
pub r: Option<CommitmentRandomness>,
|
||||
|
@ -389,7 +389,7 @@ fn test_sprout_constraints() {
|
|||
let r = Some(CommitmentRandomness(get_u256(&mut test_vector)));
|
||||
let a_sk = Some(SpendingKey(get_u256(&mut test_vector)));
|
||||
|
||||
inputs.push(JSInput {
|
||||
inputs.push(JsInput {
|
||||
value,
|
||||
a_sk,
|
||||
rho,
|
||||
|
@ -406,7 +406,7 @@ fn test_sprout_constraints() {
|
|||
get_u256(&mut test_vector);
|
||||
let r = Some(CommitmentRandomness(get_u256(&mut test_vector)));
|
||||
|
||||
outputs.push(JSOutput { value, a_pk, r });
|
||||
outputs.push(JsOutput { value, a_pk, r });
|
||||
}
|
||||
|
||||
let vpub_old = Some(test_vector.read_u64::<LittleEndian>().unwrap());
|
||||
|
|
|
@ -90,7 +90,7 @@ pub fn create_proof(
|
|||
position >>= 1;
|
||||
}
|
||||
|
||||
inputs.push(JSInput {
|
||||
inputs.push(JsInput {
|
||||
value,
|
||||
a_sk,
|
||||
rho,
|
||||
|
@ -106,7 +106,7 @@ pub fn create_proof(
|
|||
let mut outputs = Vec::with_capacity(2);
|
||||
{
|
||||
let mut handle_output = |a_pk, value, r| {
|
||||
outputs.push(JSOutput {
|
||||
outputs.push(JsOutput {
|
||||
value: Some(value),
|
||||
a_pk: Some(PayingKey(a_pk)),
|
||||
r: Some(CommitmentRandomness(r)),
|
||||
|
|
Loading…
Reference in New Issue