From af0753f0da309264a129a53ad4de5cd44057dc66 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 19 Apr 2024 22:10:57 +0000 Subject: [PATCH 01/14] upgraded NoteInterface to include value --- zingolib/src/lightclient/deprecated.rs | 1 + zingolib/src/lightclient/describe.rs | 1 - zingolib/src/wallet/describe.rs | 2 +- zingolib/src/wallet/notes/interface.rs | 8 +++----- zingolib/src/wallet/notes/orchard.rs | 4 ++++ zingolib/src/wallet/notes/sapling.rs | 4 ++++ zingolib/src/wallet/notes/transparent.rs | 4 ++++ zingolib/src/wallet/transaction_record.rs | 1 + 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/zingolib/src/lightclient/deprecated.rs b/zingolib/src/lightclient/deprecated.rs index d87fcf652..5b76b485f 100644 --- a/zingolib/src/lightclient/deprecated.rs +++ b/zingolib/src/lightclient/deprecated.rs @@ -3,6 +3,7 @@ use std::cmp; use crate::wallet::transaction_record::TransactionRecord; use super::*; +use crate::wallet::notes::NoteInterface; use crate::wallet::notes::ShieldedNoteInterface; use zcash_note_encryption::Domain; diff --git a/zingolib/src/lightclient/describe.rs b/zingolib/src/lightclient/describe.rs index 235a61250..45d787209 100644 --- a/zingolib/src/lightclient/describe.rs +++ b/zingolib/src/lightclient/describe.rs @@ -25,7 +25,6 @@ use crate::{ }, keys::address_from_pubkeyhash, notes::NoteInterface, - notes::ShieldedNoteInterface, LightWallet, Pool, }, }; diff --git a/zingolib/src/wallet/describe.rs b/zingolib/src/wallet/describe.rs index 8eadcdcba..3fca629b6 100644 --- a/zingolib/src/wallet/describe.rs +++ b/zingolib/src/wallet/describe.rs @@ -70,7 +70,7 @@ impl LightWallet { filtered_notes .map(|notedata| { if notedata.spent().is_none() && notedata.pending_spent().is_none() { - ::value(notedata) + ::value(notedata) } else { 0 } diff --git a/zingolib/src/wallet/notes/interface.rs b/zingolib/src/wallet/notes/interface.rs index 37d5d5179..0a3902a45 100644 --- a/zingolib/src/wallet/notes/interface.rs +++ b/zingolib/src/wallet/notes/interface.rs @@ -18,6 +18,9 @@ pub trait NoteInterface: Sized { /// returns the zcash_client_backend PoolType enum (one of 3) fn pool_type(&self) -> PoolType; + /// number of Zatoshis unlocked by the note + fn value(&self) -> u64; + /// TODO: Add Doc Comment Here! fn spent(&self) -> &Option<(TxId, u32)>; @@ -143,11 +146,6 @@ pub trait ShieldedNoteInterface: NoteInterface + Sized { fn transaction_metadata_notes_mut(wallet_transaction: &mut TransactionRecord) -> &mut Vec; - ///Convenience function - fn value(&self) -> u64 { - Self::value_from_note(self.note()) - } - /// TODO: Add Doc Comment Here! fn value_from_note(note: &Self::Note) -> u64; diff --git a/zingolib/src/wallet/notes/orchard.rs b/zingolib/src/wallet/notes/orchard.rs index 237a722b7..1510e70a4 100644 --- a/zingolib/src/wallet/notes/orchard.rs +++ b/zingolib/src/wallet/notes/orchard.rs @@ -47,6 +47,10 @@ impl NoteInterface for OrchardNote { PoolType::Shielded(ShieldedProtocol::Orchard) } + fn value(&self) -> u64 { + self.orchard_crypto_note.value().inner() + } + fn spent(&self) -> &Option<(TxId, u32)> { &self.spent } diff --git a/zingolib/src/wallet/notes/sapling.rs b/zingolib/src/wallet/notes/sapling.rs index 78bba6517..d60a4444c 100644 --- a/zingolib/src/wallet/notes/sapling.rs +++ b/zingolib/src/wallet/notes/sapling.rs @@ -67,6 +67,10 @@ impl NoteInterface for SaplingNote { PoolType::Shielded(ShieldedProtocol::Sapling) } + fn value(&self) -> u64 { + self.sapling_crypto_note.value().inner() + } + fn spent(&self) -> &Option<(TxId, u32)> { &self.spent } diff --git a/zingolib/src/wallet/notes/transparent.rs b/zingolib/src/wallet/notes/transparent.rs index 2f134b245..b4788d194 100644 --- a/zingolib/src/wallet/notes/transparent.rs +++ b/zingolib/src/wallet/notes/transparent.rs @@ -34,6 +34,10 @@ impl NoteInterface for TransparentNote { PoolType::Transparent } + fn value(&self) -> u64 { + self.value + } + fn spent(&self) -> &Option<(TxId, u32)> { &self.spent } diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index c4b7eda91..ed3e2776c 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -4,6 +4,7 @@ use zcash_primitives::transaction::TxId; use crate::error::ZingoLibError; use crate::wallet::notes; +use crate::wallet::notes::interface::NoteInterface; use super::{ data::{OutgoingTxData, PoolNullifier}, From cf891b4b041056beaeb493fdff9180e0c397f7fd Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 19 Apr 2024 22:25:02 +0000 Subject: [PATCH 02/14] clean TransactionRecord header part 1: remove super --- zingolib/src/wallet/transaction_record.rs | 44 ++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index ed3e2776c..48b5dadcf 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -1,15 +1,51 @@ //! TODO: Add Mod Description Here! +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use incrementalmerkletree::witness::IncrementalWitness; + +use json::JsonValue; +use log::{info, warn}; +use orchard::keys::SpendingKey as OrchardSpendingKey; +use orchard::note_encryption::OrchardDomain; +use orchard::tree::MerkleHashOrchard; +use rand::rngs::OsRng; +use rand::Rng; +use sapling_crypto::note_encryption::SaplingDomain; + +use sapling_crypto::zip32::DiversifiableFullViewingKey; + +use std::{ + cmp, + io::{self, Error, ErrorKind, Read, Write}, + sync::{atomic::AtomicU64, Arc}, + time::SystemTime, +}; +use tokio::sync::RwLock; + +use zcash_primitives::zip339::Mnemonic; + +use zcash_client_backend::proto::service::TreeState; +use zcash_encoding::{Optional, Vector}; +use zcash_note_encryption::Domain; + +use zcash_primitives::{consensus::BlockHeight, memo::Memo}; + +use zingo_status::confirmation_status::ConfirmationStatus; +use zingoconfig::ZingoConfig; + +use crate::wallet::notes::ShieldedNoteInterface; + +use crate::wallet::traits::ReadableWriteable; use zcash_primitives::transaction::TxId; use crate::error::ZingoLibError; +use crate::wallet::data::{WitnessTrees, COMMITMENT_TREE_LEVELS}; use crate::wallet::notes; -use crate::wallet::notes::interface::NoteInterface; - -use super::{ +use crate::wallet::WalletCapability; +use crate::wallet::{ data::{OutgoingTxData, PoolNullifier}, + notes::{query::NoteQuery, NoteInterface}, + traits, traits::DomainWalletExt, - *, }; /// Everything (SOMETHING) about a transaction From 91679ea573fbc1010d8e68b0083763aef937104e Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 19 Apr 2024 22:25:25 +0000 Subject: [PATCH 03/14] clean TransactionRecord header part 2: cargo fix --- zingolib/src/wallet.rs | 18 ++++++------- zingolib/src/wallet/transaction_record.rs | 31 ++++++++++------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/zingolib/src/wallet.rs b/zingolib/src/wallet.rs index cf1856c3f..f30e28ca5 100644 --- a/zingolib/src/wallet.rs +++ b/zingolib/src/wallet.rs @@ -7,11 +7,11 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use json::JsonValue; use log::{info, warn}; use orchard::keys::SpendingKey as OrchardSpendingKey; -use orchard::note_encryption::OrchardDomain; -use orchard::tree::MerkleHashOrchard; + + use rand::rngs::OsRng; use rand::Rng; -use sapling_crypto::note_encryption::SaplingDomain; + use sapling_crypto::zip32::DiversifiableFullViewingKey; @@ -25,19 +25,19 @@ use tokio::sync::RwLock; use zcash_primitives::zip339::Mnemonic; use zcash_client_backend::proto::service::TreeState; -use zcash_encoding::{Optional, Vector}; -use zcash_note_encryption::Domain; +use zcash_encoding::{Optional}; + + +use zcash_primitives::{memo::Memo}; -use zcash_primitives::{consensus::BlockHeight, memo::Memo}; -use zingo_status::confirmation_status::ConfirmationStatus; use zingoconfig::ZingoConfig; -use crate::wallet::notes::ShieldedNoteInterface; + use crate::wallet::traits::ReadableWriteable; -use self::data::{WitnessTrees, COMMITMENT_TREE_LEVELS}; +use self::data::{WitnessTrees}; use self::keys::unified::Fvk as _; use self::keys::unified::WalletCapability; diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 48b5dadcf..0c33a8157 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -2,35 +2,32 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use incrementalmerkletree::witness::IncrementalWitness; -use json::JsonValue; -use log::{info, warn}; -use orchard::keys::SpendingKey as OrchardSpendingKey; + + + use orchard::note_encryption::OrchardDomain; use orchard::tree::MerkleHashOrchard; -use rand::rngs::OsRng; -use rand::Rng; + + use sapling_crypto::note_encryption::SaplingDomain; -use sapling_crypto::zip32::DiversifiableFullViewingKey; + use std::{ - cmp, - io::{self, Error, ErrorKind, Read, Write}, - sync::{atomic::AtomicU64, Arc}, - time::SystemTime, + io::{self, Read, Write}, }; -use tokio::sync::RwLock; -use zcash_primitives::zip339::Mnemonic; -use zcash_client_backend::proto::service::TreeState; + + + use zcash_encoding::{Optional, Vector}; use zcash_note_encryption::Domain; -use zcash_primitives::{consensus::BlockHeight, memo::Memo}; +use zcash_primitives::{consensus::BlockHeight}; use zingo_status::confirmation_status::ConfirmationStatus; -use zingoconfig::ZingoConfig; + use crate::wallet::notes::ShieldedNoteInterface; @@ -38,12 +35,12 @@ use crate::wallet::traits::ReadableWriteable; use zcash_primitives::transaction::TxId; use crate::error::ZingoLibError; -use crate::wallet::data::{WitnessTrees, COMMITMENT_TREE_LEVELS}; +use crate::wallet::data::{COMMITMENT_TREE_LEVELS}; use crate::wallet::notes; use crate::wallet::WalletCapability; use crate::wallet::{ data::{OutgoingTxData, PoolNullifier}, - notes::{query::NoteQuery, NoteInterface}, + notes::{NoteInterface}, traits, traits::DomainWalletExt, }; From 67b12bbc6d3901ee676d7cffdb72110f6e44f48b Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 19 Apr 2024 22:27:11 +0000 Subject: [PATCH 04/14] clean TransactionRecord header part 3: organize headers --- zingolib/src/wallet.rs | 26 +++++------------- zingolib/src/wallet/transaction_record.rs | 33 +++++------------------ 2 files changed, 13 insertions(+), 46 deletions(-) diff --git a/zingolib/src/wallet.rs b/zingolib/src/wallet.rs index f30e28ca5..775e484e8 100644 --- a/zingolib/src/wallet.rs +++ b/zingolib/src/wallet.rs @@ -3,18 +3,10 @@ //! TODO: Add Mod Description Here use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; - use json::JsonValue; use log::{info, warn}; -use orchard::keys::SpendingKey as OrchardSpendingKey; - - use rand::rngs::OsRng; use rand::Rng; - - -use sapling_crypto::zip32::DiversifiableFullViewingKey; - use std::{ cmp, io::{self, Error, ErrorKind, Read, Write}, @@ -22,25 +14,19 @@ use std::{ time::SystemTime, }; use tokio::sync::RwLock; -use zcash_primitives::zip339::Mnemonic; +use orchard::keys::SpendingKey as OrchardSpendingKey; +use sapling_crypto::zip32::DiversifiableFullViewingKey; use zcash_client_backend::proto::service::TreeState; -use zcash_encoding::{Optional}; - - -use zcash_primitives::{memo::Memo}; - +use zcash_encoding::Optional; +use zcash_primitives::memo::Memo; +use zcash_primitives::zip339::Mnemonic; use zingoconfig::ZingoConfig; - - -use crate::wallet::traits::ReadableWriteable; - -use self::data::{WitnessTrees}; +use self::data::WitnessTrees; use self::keys::unified::Fvk as _; use self::keys::unified::WalletCapability; - use self::{ data::{BlockData, WalletZecPriceInfo}, message::Message, diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 0c33a8157..a207a0aa1 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -1,46 +1,27 @@ //! TODO: Add Mod Description Here! use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use incrementalmerkletree::witness::IncrementalWitness; - - - +use std::io::{self, Read, Write}; use orchard::note_encryption::OrchardDomain; use orchard::tree::MerkleHashOrchard; - - use sapling_crypto::note_encryption::SaplingDomain; - - - -use std::{ - io::{self, Read, Write}, -}; - - - - - use zcash_encoding::{Optional, Vector}; use zcash_note_encryption::Domain; - -use zcash_primitives::{consensus::BlockHeight}; +use zcash_primitives::consensus::BlockHeight; +use zcash_primitives::transaction::TxId; use zingo_status::confirmation_status::ConfirmationStatus; - -use crate::wallet::notes::ShieldedNoteInterface; - -use crate::wallet::traits::ReadableWriteable; -use zcash_primitives::transaction::TxId; - use crate::error::ZingoLibError; -use crate::wallet::data::{COMMITMENT_TREE_LEVELS}; +use crate::wallet::data::COMMITMENT_TREE_LEVELS; use crate::wallet::notes; +use crate::wallet::notes::ShieldedNoteInterface; +use crate::wallet::traits::ReadableWriteable; use crate::wallet::WalletCapability; use crate::wallet::{ data::{OutgoingTxData, PoolNullifier}, - notes::{NoteInterface}, + notes::NoteInterface, traits, traits::DomainWalletExt, }; From f3e66775186b1fb3202414cb3ae0771cebe2e66c Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 17:30:45 +0000 Subject: [PATCH 05/14] created test of query_sum_value. it fails absurdly --- Cargo.lock | 34 ++++++ zingolib/Cargo.toml | 1 + zingolib/src/wallet/notes/query.rs | 14 +++ zingolib/src/wallet/notes/transparent.rs | 2 +- zingolib/src/wallet/transaction_record.rs | 125 ++++++++++++++++++++++ 5 files changed, 175 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 7468bbef0..b61f4c895 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3103,6 +3103,39 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "test-case" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8" +dependencies = [ + "test-case-macros", +] + +[[package]] +name = "test-case-core" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 2.0.59", +] + +[[package]] +name = "test-case-macros" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", + "test-case-core", +] + [[package]] name = "thiserror" version = "1.0.58" @@ -4316,6 +4349,7 @@ dependencies = [ "sodiumoxide", "subtle", "tempfile", + "test-case", "tokio", "tokio-stream", "tonic", diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index 0042cbf5b..a6c4dc9c7 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -81,6 +81,7 @@ either = "1.8.1" serde = { version = "1.0.188", features = ["derive"] } sapling-crypto.workspace = true getset = "0.1.2" +test-case = "3.3.1" [dev-dependencies] portpicker = "0.1.0" diff --git a/zingolib/src/wallet/notes/query.rs b/zingolib/src/wallet/notes/query.rs index 2f3fb57f7..b9aa95477 100644 --- a/zingolib/src/wallet/notes/query.rs +++ b/zingolib/src/wallet/notes/query.rs @@ -43,6 +43,20 @@ pub struct NoteQuery { } impl NoteQuery { + /// build a query, specifying each stipulation + pub fn stipulations( + unspent: bool, + pending_spent: bool, + spent: bool, + transparent: bool, + sapling: bool, + orchard: bool, + ) -> Self { + Self::new( + NoteSpendStatusQuery::new(unspent, pending_spent, spent), + NotePoolQuery::new(transparent, sapling, orchard), + ) + } /// will the query include unspent notes? pub fn unspent(&self) -> &bool { self.spend_status().unspent() diff --git a/zingolib/src/wallet/notes/transparent.rs b/zingolib/src/wallet/notes/transparent.rs index b4788d194..e40e09171 100644 --- a/zingolib/src/wallet/notes/transparent.rs +++ b/zingolib/src/wallet/notes/transparent.rs @@ -252,7 +252,7 @@ pub mod mocks { .txid(TxId::from_bytes([0u8; 32])) .output_index(0) .script(vec![]) - .value(0) + .value(100000) .spent(None) .unconfirmed_spent(None) } diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index a207a0aa1..8fce44dbc 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -26,6 +26,8 @@ use crate::wallet::{ traits::DomainWalletExt, }; +use super::notes::query::NoteQuery; + /// Everything (SOMETHING) about a transaction #[derive(Debug)] pub struct TransactionRecord { @@ -108,6 +110,34 @@ impl TransactionRecord { } //get impl TransactionRecord { + /// Uses a query to select all notes with specific properties and sum them + pub fn query_sum_value(&self, include_notes: NoteQuery) -> u64 { + let mut sum = 0; + let spend_status_query = *include_notes.spend_status(); + if *include_notes.transparent() { + for note in self.transparent_notes.iter() { + if note.spend_status_query(spend_status_query) { + sum += note.value() + } + } + } + if *include_notes.sapling() { + for note in self.sapling_notes.iter() { + if note.spend_status_query(spend_status_query) { + sum += note.value() + } + } + } + if *include_notes.orchard() { + for note in self.orchard_notes.iter() { + if note.spend_status_query(spend_status_query) { + sum += note.value() + } + } + } + sum + } + /// TODO: Add Doc Comment Here! pub fn get_transparent_value_spent(&self) -> u64 { self.total_transparent_value_spent @@ -428,6 +458,11 @@ pub mod mocks { #[cfg(test)] mod tests { + use test_case::test_matrix; + + use crate::test_framework::mocks::default_txid; + use crate::wallet::notes::orchard::mocks::OrchardNoteBuilder; + use crate::wallet::notes::sapling::mocks::SaplingNoteBuilder; use crate::wallet::notes::transparent::mocks::TransparentNoteBuilder; use crate::wallet::transaction_record::mocks::TransactionRecordBuilder; @@ -458,4 +493,94 @@ mod tests { .push(TransparentNoteBuilder::default().build()); assert!(transaction_record.is_incoming_transaction()); } + + #[test_matrix( + [true, false], + [true, false], + [true, false], + [true, false], + [true, false], + [true, false] + )] + fn query_sum_value( + unspent: bool, + pending_spent: bool, + spent: bool, + transparent: bool, + sapling: bool, + orchard: bool, + ) { + let spend = Some((default_txid(), 112358)); + + let mut transaction_record = TransactionRecordBuilder::default().build(); + + transaction_record + .transparent_notes + .push(TransparentNoteBuilder::default().build()); + transaction_record + .transparent_notes + .push(TransparentNoteBuilder::default().spent(spend).build()); + transaction_record.transparent_notes.push( + TransparentNoteBuilder::default() + .unconfirmed_spent(spend) + .build(), + ); + transaction_record + .sapling_notes + .push(SaplingNoteBuilder::default().build()); + transaction_record + .sapling_notes + .push(SaplingNoteBuilder::default().spent(spend).build()); + transaction_record.sapling_notes.push( + SaplingNoteBuilder::default() + .unconfirmed_spent(spend) + .build(), + ); + transaction_record + .orchard_notes + .push(OrchardNoteBuilder::default().build()); + transaction_record + .orchard_notes + .push(OrchardNoteBuilder::default().spent(spend).build()); + transaction_record.orchard_notes.push( + OrchardNoteBuilder::default() + .unconfirmed_spent(spend) + .build(), + ); + + let mut valid_spend_stati = 0; + if unspent { + valid_spend_stati = valid_spend_stati + 1; + } + if pending_spent { + valid_spend_stati = valid_spend_stati + 1; + } + if spent { + valid_spend_stati = valid_spend_stati + 1; + } + let mut valid_pools = 0; + if transparent { + valid_pools = valid_pools + 1; + } + if sapling { + valid_pools = valid_pools + 1; + } + if orchard { + valid_pools = valid_pools + 1; + } + + let expected = valid_spend_stati * valid_pools * 100000; + + assert_eq!( + transaction_record.query_sum_value(NoteQuery::stipulations( + unspent, + pending_spent, + spent, + transparent, + sapling, + orchard, + )), + expected, + ); + } } From b34d9366e1d847f764749b4df8e60b233bb8ff4a Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 17:37:35 +0000 Subject: [PATCH 06/14] fixed test --- zingolib/src/test_framework/mocks.rs | 4 ++-- zingolib/src/wallet/transaction_record.rs | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/zingolib/src/test_framework/mocks.rs b/zingolib/src/test_framework/mocks.rs index e25591c43..7d518be9a 100644 --- a/zingolib/src/test_framework/mocks.rs +++ b/zingolib/src/test_framework/mocks.rs @@ -123,7 +123,7 @@ mod sapling_crypto_note { let (_, _, address) = default_zaddr(); Self::new() .recipient(address) - .value(NoteValue::from_raw(1000000)) + .value(NoteValue::from_raw(200000)) .rseed(Rseed::AfterZip212([7; 32])) } } @@ -158,7 +158,7 @@ pub mod orchard_note { let fvk: FullViewingKey = (&sk).into(); let recipient = fvk.address_at(0u32, Scope::External); - let value = NoteValue::default(); // ZERO + let value = NoteValue::from_raw(800000); let rho = { loop { let mut bytes = [0u8; 32]; diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 8fce44dbc..05446c4da 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -558,18 +558,19 @@ mod tests { if spent { valid_spend_stati = valid_spend_stati + 1; } - let mut valid_pools = 0; + //different pools have different mock values. + let mut valid_pool_value = 0; if transparent { - valid_pools = valid_pools + 1; + valid_pool_value = valid_pool_value + 100000; } if sapling { - valid_pools = valid_pools + 1; + valid_pool_value = valid_pool_value + 200000; } if orchard { - valid_pools = valid_pools + 1; + valid_pool_value = valid_pool_value + 800000; } - let expected = valid_spend_stati * valid_pools * 100000; + let expected = valid_spend_stati * valid_pool_value; assert_eq!( transaction_record.query_sum_value(NoteQuery::stipulations( From 42f8cd69449c408f7f5ced9feb85e8dddc298083 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 17:58:39 +0000 Subject: [PATCH 07/14] added query_for_ids --- zingolib/src/wallet/transaction_record.rs | 138 +++++++++++++++++++--- 1 file changed, 121 insertions(+), 17 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 05446c4da..5543bafb5 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -2,6 +2,7 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use incrementalmerkletree::witness::IncrementalWitness; use std::io::{self, Read, Write}; +use zcash_client_backend::PoolType; use orchard::note_encryption::OrchardDomain; use orchard::tree::MerkleHashOrchard; @@ -27,6 +28,7 @@ use crate::wallet::{ }; use super::notes::query::NoteQuery; +use super::notes::NoteRecordIdentifier; /// Everything (SOMETHING) about a transaction #[derive(Debug)] @@ -110,6 +112,50 @@ impl TransactionRecord { } //get impl TransactionRecord { + /// Uses a query to select all notes with specific properties and return a vector of their identifiers + pub fn query_for_ids(&self, include_notes: NoteQuery) -> Vec { + let mut set = vec![]; + let spend_status_query = *include_notes.spend_status(); + if *include_notes.transparent() { + for note in self.transparent_notes.iter() { + if note.spend_status_query(spend_status_query) { + set.push(NoteRecordIdentifier::from_parts( + self.txid, + PoolType::Transparent, + note.output_index as u32, + )); + } + } + } + if *include_notes.sapling() { + for note in self.sapling_notes.iter() { + if note.spend_status_query(spend_status_query) { + if let Some(output_index) = note.output_index { + set.push(NoteRecordIdentifier::from_parts( + self.txid, + PoolType::Transparent, + output_index as u32, + )); + } + } + } + } + if *include_notes.orchard() { + for note in self.orchard_notes.iter() { + if note.spend_status_query(spend_status_query) { + if let Some(output_index) = note.output_index { + set.push(NoteRecordIdentifier::from_parts( + self.txid, + PoolType::Transparent, + output_index as u32, + )); + } + } + } + } + set + } + /// Uses a query to select all notes with specific properties and sum them pub fn query_sum_value(&self, include_notes: NoteQuery) -> u64 { let mut sum = 0; @@ -494,22 +540,7 @@ mod tests { assert!(transaction_record.is_incoming_transaction()); } - #[test_matrix( - [true, false], - [true, false], - [true, false], - [true, false], - [true, false], - [true, false] - )] - fn query_sum_value( - unspent: bool, - pending_spent: bool, - spent: bool, - transparent: bool, - sapling: bool, - orchard: bool, - ) { + fn nine_note_transaction_record() -> TransactionRecord { let spend = Some((default_txid(), 112358)); let mut transaction_record = TransactionRecordBuilder::default().build(); @@ -548,6 +579,79 @@ mod tests { .build(), ); + transaction_record + } + + #[test_matrix( + [true, false], + [true, false], + [true, false], + [true, false], + [true, false], + [true, false] + )] + fn query_for_ids( + unspent: bool, + pending_spent: bool, + spent: bool, + transparent: bool, + sapling: bool, + orchard: bool, + ) { + let mut valid_spend_stati = 0; + if unspent { + valid_spend_stati = valid_spend_stati + 1; + } + if pending_spent { + valid_spend_stati = valid_spend_stati + 1; + } + if spent { + valid_spend_stati = valid_spend_stati + 1; + } + let mut valid_pools = 0; + if transparent { + valid_pools = valid_pools + 1; + } + if sapling { + valid_pools = valid_pools + 1; + } + if orchard { + valid_pools = valid_pools + 1; + } + + let expected = valid_spend_stati * valid_pools; + + assert_eq!( + nine_note_transaction_record() + .query_for_ids(NoteQuery::stipulations( + unspent, + pending_spent, + spent, + transparent, + sapling, + orchard, + )) + .len(), + expected, + ); + } + + #[test_matrix( + [true, false], + [true, false], + [true, false], + [true, false], + [true, false], + [true, false] + )] + fn query_sum_value( + unspent: bool, + pending_spent: bool, + spent: bool, + transparent: bool, + sapling: bool, + orchard: bool, + ) { let mut valid_spend_stati = 0; if unspent { valid_spend_stati = valid_spend_stati + 1; @@ -573,7 +677,7 @@ mod tests { let expected = valid_spend_stati * valid_pool_value; assert_eq!( - transaction_record.query_sum_value(NoteQuery::stipulations( + nine_note_transaction_record().query_sum_value(NoteQuery::stipulations( unspent, pending_spent, spent, From 60b476c5b46ff80a106c179d1efddadd32496ded Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 18:28:56 +0000 Subject: [PATCH 08/14] named OutputQuery --- zingolib/src/wallet/notes.rs | 28 +++++++++++------------ zingolib/src/wallet/notes/interface.rs | 8 +++---- zingolib/src/wallet/notes/query.rs | 16 ++++++------- zingolib/src/wallet/transaction_record.rs | 12 +++++----- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/zingolib/src/wallet/notes.rs b/zingolib/src/wallet/notes.rs index a68369767..2581d8e30 100644 --- a/zingolib/src/wallet/notes.rs +++ b/zingolib/src/wallet/notes.rs @@ -131,12 +131,12 @@ pub mod tests { use crate::{ test_framework::mocks::default_txid, wallet::notes::{ - query::NoteQuery, sapling::mocks::SaplingNoteBuilder, + query::OutputQuery, sapling::mocks::SaplingNoteBuilder, transparent::mocks::TransparentNoteBuilder, NoteInterface, }, }; - use super::query::{NotePoolQuery, NoteSpendStatusQuery}; + use super::query::{OutputPoolQuery, OutputSpendStatusQuery}; #[test] fn note_queries() { @@ -153,22 +153,22 @@ pub mod tests { .build(); let sapling_spent_note = SaplingNoteBuilder::default().spent(spend).build(); - let unspent_query = NoteSpendStatusQuery::new(true, false, false); - let pending_or_spent_query = NoteSpendStatusQuery::new(false, true, true); - let spent_query = NoteSpendStatusQuery::new(false, false, true); + let unspent_query = OutputSpendStatusQuery::new(true, false, false); + let pending_or_spent_query = OutputSpendStatusQuery::new(false, true, true); + let spent_query = OutputSpendStatusQuery::new(false, false, true); - let transparent_query = NotePoolQuery::new(true, false, false); - let shielded_query = NotePoolQuery::new(false, true, true); - let any_pool_query = NotePoolQuery::new(true, true, true); + let transparent_query = OutputPoolQuery::new(true, false, false); + let shielded_query = OutputPoolQuery::new(false, true, true); + let any_pool_query = OutputPoolQuery::new(true, true, true); - let unspent_transparent_query = NoteQuery::new(unspent_query, transparent_query); - let unspent_any_pool_query = NoteQuery::new(unspent_query, any_pool_query); + let unspent_transparent_query = OutputQuery::new(unspent_query, transparent_query); + let unspent_any_pool_query = OutputQuery::new(unspent_query, any_pool_query); let pending_or_spent_transparent_query = - NoteQuery::new(pending_or_spent_query, transparent_query); + OutputQuery::new(pending_or_spent_query, transparent_query); let pending_or_spent_shielded_query = - NoteQuery::new(pending_or_spent_query, shielded_query); - let spent_shielded_query = NoteQuery::new(spent_query, shielded_query); - let spent_any_pool_query = NoteQuery::new(spent_query, any_pool_query); + OutputQuery::new(pending_or_spent_query, shielded_query); + let spent_shielded_query = OutputQuery::new(spent_query, shielded_query); + let spent_any_pool_query = OutputQuery::new(spent_query, any_pool_query); assert!(transparent_unspent_note.query(unspent_transparent_query)); assert!(transparent_unspent_note.query(unspent_any_pool_query)); diff --git a/zingolib/src/wallet/notes/interface.rs b/zingolib/src/wallet/notes/interface.rs index 0a3902a45..7481bb09a 100644 --- a/zingolib/src/wallet/notes/interface.rs +++ b/zingolib/src/wallet/notes/interface.rs @@ -10,7 +10,7 @@ use super::{ traits::{FromBytes, FromCommitment, Nullifier, ReadableWriteable, ToBytes}, Pool, }, - query::{NotePoolQuery, NoteQuery, NoteSpendStatusQuery}, + query::{OutputPoolQuery, OutputQuery, OutputSpendStatusQuery}, }; /// TODO: Add Doc Comment Here! @@ -49,14 +49,14 @@ pub trait NoteInterface: Sized { } /// Returns true if the note has one of the spend statuses enumerated by the query - fn spend_status_query(&self, query: NoteSpendStatusQuery) -> bool { + fn spend_status_query(&self, query: OutputSpendStatusQuery) -> bool { (*query.unspent() && !self.is_spent() && !self.is_pending_spent()) || (*query.pending_spent() && self.is_pending_spent()) || (*query.spent() && self.is_spent()) } /// Returns true if the note is one of the pools enumerated by the query. - fn pool_query(&self, query: NotePoolQuery) -> bool { + fn pool_query(&self, query: OutputPoolQuery) -> bool { (*query.transparent() && self.pool_type() == PoolType::Transparent) || (*query.sapling() && self.pool_type() == PoolType::Shielded(ShieldedProtocol::Sapling)) @@ -65,7 +65,7 @@ pub trait NoteInterface: Sized { } /// Returns true if the note is one of the spend statuses enumerated by the query AND one of the pools enumerated by the query. - fn query(&self, query: NoteQuery) -> bool { + fn query(&self, query: OutputQuery) -> bool { self.spend_status_query(*query.spend_status()) && self.pool_query(*query.pools()) } } diff --git a/zingolib/src/wallet/notes/query.rs b/zingolib/src/wallet/notes/query.rs index b9aa95477..98eeca6a8 100644 --- a/zingolib/src/wallet/notes/query.rs +++ b/zingolib/src/wallet/notes/query.rs @@ -5,7 +5,7 @@ use getset::Getters; /// Selects received notes by how they been spent #[derive(Getters, Constructor, Clone, Copy)] -pub struct NoteSpendStatusQuery { +pub struct OutputSpendStatusQuery { /// will the query include unspent notes? #[getset(get = "pub")] unspent: bool, @@ -19,7 +19,7 @@ pub struct NoteSpendStatusQuery { /// Selects received notes by pool #[derive(Getters, Constructor, Clone, Copy)] -pub struct NotePoolQuery { +pub struct OutputPoolQuery { /// will the query include transparent notes? (coins) #[getset(get = "pub")] transparent: bool, @@ -33,16 +33,16 @@ pub struct NotePoolQuery { /// Selects received notes by any properties #[derive(Getters, Constructor, Clone, Copy)] -pub struct NoteQuery { +pub struct OutputQuery { /// selects spend status properties #[getset(get = "pub")] - spend_status: NoteSpendStatusQuery, + spend_status: OutputSpendStatusQuery, /// selects pools #[getset(get = "pub")] - pools: NotePoolQuery, + pools: OutputPoolQuery, } -impl NoteQuery { +impl OutputQuery { /// build a query, specifying each stipulation pub fn stipulations( unspent: bool, @@ -53,8 +53,8 @@ impl NoteQuery { orchard: bool, ) -> Self { Self::new( - NoteSpendStatusQuery::new(unspent, pending_spent, spent), - NotePoolQuery::new(transparent, sapling, orchard), + OutputSpendStatusQuery::new(unspent, pending_spent, spent), + OutputPoolQuery::new(transparent, sapling, orchard), ) } /// will the query include unspent notes? diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index b78096b1f..0e9d2e04d 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -15,7 +15,7 @@ use crate::wallet::{ data::{OutgoingTxData, PoolNullifier, COMMITMENT_TREE_LEVELS}, keys::unified::WalletCapability, notes::{ - query::NoteQuery, OrchardNote, OutputId, SaplingNote, ShieldedNoteInterface, + query::OutputQuery, OrchardNote, OutputId, SaplingNote, ShieldedNoteInterface, TransparentNote, }, traits::DomainWalletExt, @@ -108,7 +108,7 @@ impl TransactionRecord { //get impl TransactionRecord { /// Uses a query to select all notes with specific properties and return a vector of their identifiers - pub fn query_for_ids(&self, include_notes: NoteQuery) -> Vec { + pub fn query_for_ids(&self, include_notes: OutputQuery) -> Vec { let mut set = vec![]; let spend_status_query = *include_notes.spend_status(); if *include_notes.transparent() { @@ -152,7 +152,7 @@ impl TransactionRecord { } /// Uses a query to select all notes with specific properties and sum them - pub fn query_sum_value(&self, include_notes: NoteQuery) -> u64 { + pub fn query_sum_value(&self, include_notes: OutputQuery) -> u64 { let mut sum = 0; let spend_status_query = *include_notes.spend_status(); if *include_notes.transparent() { @@ -510,7 +510,7 @@ mod tests { use crate::test_framework::mocks::default_txid; use crate::wallet::notes::orchard::mocks::OrchardNoteBuilder; - use crate::wallet::notes::query::NoteQuery; + use crate::wallet::notes::query::OutputQuery; use crate::wallet::notes::sapling::mocks::SaplingNoteBuilder; use crate::wallet::notes::transparent::mocks::TransparentNoteBuilder; use crate::wallet::transaction_record::mocks::TransactionRecordBuilder; @@ -632,7 +632,7 @@ mod tests { assert_eq!( nine_note_transaction_record() - .query_for_ids(NoteQuery::stipulations( + .query_for_ids(OutputQuery::stipulations( unspent, pending_spent, spent, @@ -686,7 +686,7 @@ mod tests { let expected = valid_spend_stati * valid_pool_value; assert_eq!( - nine_note_transaction_record().query_sum_value(NoteQuery::stipulations( + nine_note_transaction_record().query_sum_value(OutputQuery::stipulations( unspent, pending_spent, spent, From 7f0f2511adc21434c83b132aa5fbed7b1d4fee2e Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 18:47:17 +0000 Subject: [PATCH 09/14] used query for total_value_received --- zingolib/src/wallet/transaction_record.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 0e9d2e04d..8db462c65 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -255,15 +255,11 @@ impl TransactionRecord { + self.pool_change_returned::() } - /// TODO: Add Doc Comment Here! + /// Sums all the received notes in the transaction. pub fn total_value_received(&self) -> u64 { - self.pool_value_received::() - + self.pool_value_received::() - + self - .transparent_notes - .iter() - .map(|utxo| utxo.value) - .sum::() + self.query_sum_value(OutputQuery::stipulations( + true, true, true, true, true, true, + )) } /// TODO: Add Doc Comment Here! From 730e9b646930ff6a34f1de045b7f078821bc1c5d Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 18:51:17 +0000 Subject: [PATCH 10/14] cargo clippy --- zingolib/src/wallet/transaction_record.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 8db462c65..7bdb7d6f1 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -129,7 +129,7 @@ impl TransactionRecord { set.push(OutputId::from_parts( self.txid, PoolType::Transparent, - output_index as u32, + output_index, )); } } @@ -142,7 +142,7 @@ impl TransactionRecord { set.push(OutputId::from_parts( self.txid, PoolType::Transparent, - output_index as u32, + output_index, )); } } From 9282e232579e500647335e7cf594727cc43f01ef Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 18:52:30 +0000 Subject: [PATCH 11/14] cargo clippy --tests --- zingolib/src/wallet/transaction_record.rs | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 7bdb7d6f1..d7f1b4fd6 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -605,23 +605,23 @@ mod tests { ) { let mut valid_spend_stati = 0; if unspent { - valid_spend_stati = valid_spend_stati + 1; + valid_spend_stati += 1; } if pending_spent { - valid_spend_stati = valid_spend_stati + 1; + valid_spend_stati += 1; } if spent { - valid_spend_stati = valid_spend_stati + 1; + valid_spend_stati += 1; } let mut valid_pools = 0; if transparent { - valid_pools = valid_pools + 1; + valid_pools += 1; } if sapling { - valid_pools = valid_pools + 1; + valid_pools += 1; } if orchard { - valid_pools = valid_pools + 1; + valid_pools += 1; } let expected = valid_spend_stati * valid_pools; @@ -659,24 +659,24 @@ mod tests { ) { let mut valid_spend_stati = 0; if unspent { - valid_spend_stati = valid_spend_stati + 1; + valid_spend_stati += 1; } if pending_spent { - valid_spend_stati = valid_spend_stati + 1; + valid_spend_stati += 1; } if spent { - valid_spend_stati = valid_spend_stati + 1; + valid_spend_stati += 1; } //different pools have different mock values. let mut valid_pool_value = 0; if transparent { - valid_pool_value = valid_pool_value + 100000; + valid_pool_value += 100000; } if sapling { - valid_pool_value = valid_pool_value + 200000; + valid_pool_value += 200000; } if orchard { - valid_pool_value = valid_pool_value + 800000; + valid_pool_value += 800000; } let expected = valid_spend_stati * valid_pool_value; From f606e25ecaabc6cec78c04a38a630ab1f1f2c8f3 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 19:06:34 +0000 Subject: [PATCH 12/14] added test for total_value_received --- zingolib/src/wallet/transaction_record.rs | 112 +++++++++++++--------- 1 file changed, 68 insertions(+), 44 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index d7f1b4fd6..d41a66403 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -445,7 +445,13 @@ pub mod mocks { use zcash_primitives::transaction::TxId; use zingo_status::confirmation_status::ConfirmationStatus; - use crate::test_framework::mocks::build_method; + use crate::{ + test_framework::mocks::{build_method, default_txid}, + wallet::notes::{ + orchard::mocks::OrchardNoteBuilder, sapling::mocks::SaplingNoteBuilder, + transparent::mocks::TransparentNoteBuilder, + }, + }; use super::TransactionRecord; @@ -498,6 +504,49 @@ pub mod mocks { } } } + + /// creates a TransactionRecord holding each type of note. + pub fn nine_note_transaction_record() -> TransactionRecord { + let spend = Some((default_txid(), 112358)); + + let mut transaction_record = TransactionRecordBuilder::default().build(); + + transaction_record + .transparent_notes + .push(TransparentNoteBuilder::default().build()); + transaction_record + .transparent_notes + .push(TransparentNoteBuilder::default().spent(spend).build()); + transaction_record.transparent_notes.push( + TransparentNoteBuilder::default() + .unconfirmed_spent(spend) + .build(), + ); + transaction_record + .sapling_notes + .push(SaplingNoteBuilder::default().build()); + transaction_record + .sapling_notes + .push(SaplingNoteBuilder::default().spent(spend).build()); + transaction_record.sapling_notes.push( + SaplingNoteBuilder::default() + .unconfirmed_spent(spend) + .build(), + ); + transaction_record + .orchard_notes + .push(OrchardNoteBuilder::default().build()); + transaction_record + .orchard_notes + .push(OrchardNoteBuilder::default().spent(spend).build()); + transaction_record.orchard_notes.push( + OrchardNoteBuilder::default() + .unconfirmed_spent(spend) + .build(), + ); + + transaction_record + } } #[cfg(test)] @@ -509,7 +558,9 @@ mod tests { use crate::wallet::notes::query::OutputQuery; use crate::wallet::notes::sapling::mocks::SaplingNoteBuilder; use crate::wallet::notes::transparent::mocks::TransparentNoteBuilder; - use crate::wallet::transaction_record::mocks::TransactionRecordBuilder; + use crate::wallet::transaction_record::mocks::{ + nine_note_transaction_record, TransactionRecordBuilder, + }; use super::TransactionRecord; @@ -545,48 +596,6 @@ mod tests { assert!(transaction_record.is_incoming_transaction()); } - fn nine_note_transaction_record() -> TransactionRecord { - let spend = Some((default_txid(), 112358)); - - let mut transaction_record = TransactionRecordBuilder::default().build(); - - transaction_record - .transparent_notes - .push(TransparentNoteBuilder::default().build()); - transaction_record - .transparent_notes - .push(TransparentNoteBuilder::default().spent(spend).build()); - transaction_record.transparent_notes.push( - TransparentNoteBuilder::default() - .unconfirmed_spent(spend) - .build(), - ); - transaction_record - .sapling_notes - .push(SaplingNoteBuilder::default().build()); - transaction_record - .sapling_notes - .push(SaplingNoteBuilder::default().spent(spend).build()); - transaction_record.sapling_notes.push( - SaplingNoteBuilder::default() - .unconfirmed_spent(spend) - .build(), - ); - transaction_record - .orchard_notes - .push(OrchardNoteBuilder::default().build()); - transaction_record - .orchard_notes - .push(OrchardNoteBuilder::default().spent(spend).build()); - transaction_record.orchard_notes.push( - OrchardNoteBuilder::default() - .unconfirmed_spent(spend) - .build(), - ); - - transaction_record - } - #[test_matrix( [true, false], [true, false], @@ -693,4 +702,19 @@ mod tests { expected, ); } + + #[test] + fn total_value_received() { + let transaction_record = nine_note_transaction_record(); + let old_total = transaction_record + .pool_value_received::() + + transaction_record + .pool_value_received::() + + transaction_record + .transparent_notes + .iter() + .map(|utxo| utxo.value) + .sum::(); + assert_eq!(transaction_record.total_value_received(), old_total); + } } From 75c02ee99faafc851d9ade35bd827cda67c59183 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 19:08:04 +0000 Subject: [PATCH 13/14] cargo clippy --tests --- zingolib/src/wallet/transaction_record.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index d41a66403..976cc507d 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -553,16 +553,16 @@ pub mod mocks { mod tests { use test_case::test_matrix; - use crate::test_framework::mocks::default_txid; - use crate::wallet::notes::orchard::mocks::OrchardNoteBuilder; + + use crate::wallet::notes::query::OutputQuery; - use crate::wallet::notes::sapling::mocks::SaplingNoteBuilder; + use crate::wallet::notes::transparent::mocks::TransparentNoteBuilder; use crate::wallet::transaction_record::mocks::{ nine_note_transaction_record, TransactionRecordBuilder, }; - use super::TransactionRecord; + #[test] pub fn blank_record() { From 644c2027427fd28b36239bd569b9e52b9a4f014a Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 22 Apr 2024 19:09:06 +0000 Subject: [PATCH 14/14] newlines --- zingolib/src/wallet/transaction_record.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/zingolib/src/wallet/transaction_record.rs b/zingolib/src/wallet/transaction_record.rs index 976cc507d..acfa6d218 100644 --- a/zingolib/src/wallet/transaction_record.rs +++ b/zingolib/src/wallet/transaction_record.rs @@ -553,17 +553,13 @@ pub mod mocks { mod tests { use test_case::test_matrix; - - use crate::wallet::notes::query::OutputQuery; - + use crate::wallet::notes::transparent::mocks::TransparentNoteBuilder; use crate::wallet::transaction_record::mocks::{ nine_note_transaction_record, TransactionRecordBuilder, }; - - #[test] pub fn blank_record() { let new = TransactionRecordBuilder::default().build();