From 9712c5c543ba7996a5d0f6b923a5c8b0a8cffa8d Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Thu, 25 Apr 2024 22:12:10 +0000 Subject: [PATCH 1/7] new mod trait_stub_inputsource --- zingolib/src/wallet/tx_map_and_maybe_trees.rs | 1 + .../trait_stub_inputsource.rs | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs diff --git a/zingolib/src/wallet/tx_map_and_maybe_trees.rs b/zingolib/src/wallet/tx_map_and_maybe_trees.rs index 70cc844b9..ca1719167 100644 --- a/zingolib/src/wallet/tx_map_and_maybe_trees.rs +++ b/zingolib/src/wallet/tx_map_and_maybe_trees.rs @@ -42,4 +42,5 @@ impl TxMapAndMaybeTrees { } } +pub mod trait_stub_inputsource; pub mod trait_walletread; diff --git a/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs new file mode 100644 index 000000000..aef5a1d78 --- /dev/null +++ b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs @@ -0,0 +1,86 @@ +//! this mod brings input source functionality from transaction_records_by_id + +use orchard::note_encryption::OrchardDomain; +use sapling_crypto::note_encryption::SaplingDomain; +use zcash_client_backend::{ + data_api::{InputSource, SpendableNotes}, + wallet::{ReceivedNote, WalletTransparentOutput}, + ShieldedProtocol, +}; +use zcash_primitives::{ + legacy::Script, + transaction::components::{amount::NonNegativeAmount, TxOut}, +}; +use zip32::AccountId; + +use crate::{ + error::{ZingoLibError, ZingoLibResult}, + wallet::{ + notes::{query::OutputSpendStatusQuery, OutputInterface, ShNoteId}, + transaction_records_by_id::TransactionRecordsById, + }, +}; + +use super::TxMapAndMaybeTrees; + +/// A trait representing the capability to query a data store for unspent transaction outputs belonging to a wallet. +/// combining this with WalletRead unlocks propose_transaction +/// all implementations in this file redirect to transaction_records_by_id +impl InputSource for TxMapAndMaybeTrees { + type Error = ZingoLibError; + type AccountId = zcash_primitives::zip32::AccountId; + type NoteRef = ShNoteId; + + fn get_spendable_note( + &self, + txid: &zcash_primitives::transaction::TxId, + protocol: zcash_client_backend::ShieldedProtocol, + index: u32, + ) -> Result< + Option< + zcash_client_backend::wallet::ReceivedNote< + Self::NoteRef, + zcash_client_backend::wallet::Note, + >, + >, + Self::Error, + > { + self.transaction_records_by_id + .get_spendable_note(txid, protocol, index) + } + + fn select_spendable_notes( + &self, + account: Self::AccountId, + target_value: zcash_primitives::transaction::components::amount::NonNegativeAmount, + sources: &[zcash_client_backend::ShieldedProtocol], + anchor_height: zcash_primitives::consensus::BlockHeight, + exclude: &[Self::NoteRef], + ) -> Result, ZingoLibError> { + self.transaction_records_by_id.select_spendable_notes( + account, + target_value, + sources, + anchor_height, + exclude, + ) + } + + fn get_unspent_transparent_output( + &self, + outpoint: &zcash_primitives::transaction::components::OutPoint, + ) -> Result, Self::Error> { + self.transaction_records_by_id + .get_unspent_transparent_output(outpoint) + } + + fn get_unspent_transparent_outputs( + &self, + address: &zcash_primitives::legacy::TransparentAddress, + max_height: zcash_primitives::consensus::BlockHeight, + exclude: &[zcash_primitives::transaction::components::OutPoint], + ) -> Result, Self::Error> { + self.transaction_records_by_id + .get_unspent_transparent_outputs(address, max_height, exclude) + } +} From 1a80d7eacb4137af736fa6fe35228e111c6feda6 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Thu, 25 Apr 2024 22:12:44 +0000 Subject: [PATCH 2/7] cargo fix --- .../trait_stub_inputsource.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs index aef5a1d78..b956c1fe5 100644 --- a/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs +++ b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs @@ -1,23 +1,17 @@ //! this mod brings input source functionality from transaction_records_by_id -use orchard::note_encryption::OrchardDomain; -use sapling_crypto::note_encryption::SaplingDomain; + + use zcash_client_backend::{ data_api::{InputSource, SpendableNotes}, - wallet::{ReceivedNote, WalletTransparentOutput}, - ShieldedProtocol, -}; -use zcash_primitives::{ - legacy::Script, - transaction::components::{amount::NonNegativeAmount, TxOut}, }; -use zip32::AccountId; + + use crate::{ - error::{ZingoLibError, ZingoLibResult}, + error::{ZingoLibError}, wallet::{ - notes::{query::OutputSpendStatusQuery, OutputInterface, ShNoteId}, - transaction_records_by_id::TransactionRecordsById, + notes::{ShNoteId}, }, }; From e12413bda32cdcd8996bf28b5121c278bc59f9a9 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 26 Apr 2024 15:47:55 +0000 Subject: [PATCH 3/7] mostly invoked propose_transfer --- zingolib/src/data.rs | 2 +- zingolib/src/lightclient.rs | 6 +-- zingolib/src/lightclient/send.rs | 82 +++++++++++++++++++++++++++++--- 3 files changed, 79 insertions(+), 11 deletions(-) diff --git a/zingolib/src/data.rs b/zingolib/src/data.rs index bb7b728e6..cbf2c2622 100644 --- a/zingolib/src/data.rs +++ b/zingolib/src/data.rs @@ -1,4 +1,4 @@ //! This is a mod for data structs that will be used across all sections of zingolib. -#[cfg(feature = "zip317")] +// #[cfg(feature = "zip317")] pub mod proposal; pub mod witness_trees; diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index 8eb59646b..3bbec0365 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -19,7 +19,7 @@ use crate::{ wallet::{keys::unified::ReceiverSelection, message::Message, LightWallet, SendProgress}, }; -#[cfg(feature = "zip317")] +// #[cfg(feature = "zip317")] use crate::data::proposal::ZingoProposal; /// TODO: Add Doc Comment Here! @@ -235,7 +235,7 @@ pub struct LightClient { bsync_data: Arc>, interrupt_sync: Arc>, - #[cfg(feature = "zip317")] + // #[cfg(feature = "zip317")] latest_proposal: Arc>>, save_buffer: ZingoSaveBuffer, @@ -278,7 +278,7 @@ pub mod instantiation { sync_lock: Mutex::new(()), bsync_data: Arc::new(RwLock::new(BlazeSyncData::new(&config))), interrupt_sync: Arc::new(RwLock::new(false)), - #[cfg(feature = "zip317")] + // #[cfg(feature = "zip317")] latest_proposal: Arc::new(RwLock::new(None)), save_buffer: ZingoSaveBuffer::new(buffer), }) diff --git a/zingolib/src/lightclient/send.rs b/zingolib/src/lightclient/send.rs index 1d7c049e0..5b0213f6e 100644 --- a/zingolib/src/lightclient/send.rs +++ b/zingolib/src/lightclient/send.rs @@ -1,20 +1,56 @@ //! TODO: Add Mod Description Here! +use std::num::NonZeroU32; + use log::debug; -use zcash_client_backend::address::Address; +use zcash_client_backend::{ + address::Address, + data_api::wallet::input_selection::GreedyInputSelector, + zip321::{Payment, TransactionRequest}, + ShieldedProtocol, +}; use zcash_primitives::{ consensus::BlockHeight, memo::MemoBytes, transaction::{components::amount::NonNegativeAmount, fees::zip317::MINIMUM_FEE}, }; use zcash_proofs::prover::LocalTxProver; +use zingoconfig::ChainType; use super::{LightClient, LightWalletSendProgress}; -use crate::{utils::zatoshis_from_u64, wallet::Pool}; +use crate::{ + error::ZingoLibError, + utils::zatoshis_from_u64, + wallet::{tx_map_and_maybe_trees::TxMapAndMaybeTrees, Pool}, +}; -#[cfg(feature = "zip317")] +// #[cfg(feature = "zip317")] use zcash_primitives::transaction::TxId; +type GISKit = GreedyInputSelector< + TxMapAndMaybeTrees, + zcash_client_backend::fees::zip317::SingleOutputChangeStrategy, +>; + +/// converts from raw receivers to TransactionRequest +pub fn receivers_becomes_transaction_request( + receivers: Vec<(Address, NonNegativeAmount, Option)>, +) -> Result { + let mut payments = vec![]; + for out in receivers.clone() { + payments.push(Payment { + recipient_address: out.0, + amount: out.1, + memo: out.2, + label: None, + message: None, + other_params: vec![], + }); + } + + TransactionRequest::new(payments) +} + impl LightClient { async fn get_submission_height(&self) -> Result { Ok(BlockHeight::from_u32( @@ -27,14 +63,46 @@ impl LightClient { /// Unstable function to expose the zip317 interface for development // TOdo: add correct functionality and doc comments / tests // TODO: Add migrate_sapling_to_orchard argument - #[cfg(feature = "zip317")] + // #[cfg(feature = "zip317")] pub async fn do_propose_spend( &self, - _receivers: Vec<(Address, NonNegativeAmount, Option)>, + receivers: Vec<(Address, NonNegativeAmount, Option)>, ) -> Result { - use crate::test_framework::mocks::ProposalBuilder; + let request = receivers_becomes_transaction_request(receivers)?; + + let change_strategy = zcash_client_backend::fees::zip317::SingleOutputChangeStrategy::new( + zcash_primitives::transaction::fees::zip317::FeeRule::standard(), + None, + ShieldedProtocol::Orchard, + ); // review consider change strategy! + + let input_selector = GISKit::new( + change_strategy, + zcash_client_backend::fees::DustOutputPolicy::default(), + ); + + let tmamt = self + .wallet + .transaction_context + .transaction_metadata_set + .write() + .await; + + let proposal = zcash_client_backend::data_api::wallet::propose_transfer::< + TxMapAndMaybeTrees, + ChainType, + GISKit, + ZingoLibError, + >( + &mut tmamt, + &self.wallet.transaction_context.config.chain, + zcash_primitives::zip32::AccountId::ZERO, + &input_selector, + request, + NonZeroU32::new(1).expect("yeep yop"), //review! be more specific + ) + .map_err(|e| ZingoLibError::Error(format!("{}", e)))?; - let proposal = ProposalBuilder::default().build(); let mut latest_proposal_lock = self.latest_proposal.write().await; *latest_proposal_lock = Some(crate::data::proposal::ZingoProposal::Transfer( proposal.clone(), From 17ce26dc0a52217d8198b75eaf7d3c57b3705f06 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 26 Apr 2024 18:09:38 +0000 Subject: [PATCH 4/7] mapped errors in tmamt --- .../src/wallet/transaction_records_by_id.rs | 2 +- .../trait_inputsource.rs | 2 +- zingolib/src/wallet/tx_map_and_maybe_trees.rs | 4 +++ .../trait_stub_inputsource.rs | 33 +++++++------------ 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/zingolib/src/wallet/transaction_records_by_id.rs b/zingolib/src/wallet/transaction_records_by_id.rs index 3836fe2af..b8728a286 100644 --- a/zingolib/src/wallet/transaction_records_by_id.rs +++ b/zingolib/src/wallet/transaction_records_by_id.rs @@ -17,7 +17,7 @@ use zcash_primitives::consensus::BlockHeight; use zcash_primitives::transaction::TxId; -mod trait_inputsource; +pub mod trait_inputsource; use super::notes::query::OutputSpendStatusQuery; diff --git a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs index 4fbaa8e99..d78cfaabf 100644 --- a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs +++ b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs @@ -132,7 +132,7 @@ impl InputSource for TransactionRecordsById { sources: &[zcash_client_backend::ShieldedProtocol], anchor_height: zcash_primitives::consensus::BlockHeight, exclude: &[Self::NoteRef], - ) -> Result, InputSourceError> { + ) -> Result, Self::Error> { let mut sapling_note_noteref_pairs: Vec<(sapling_crypto::Note, NoteId)> = Vec::new(); let mut orchard_note_noteref_pairs: Vec<(orchard::Note, NoteId)> = Vec::new(); for transaction_record in self.values().filter(|transaction_record| { diff --git a/zingolib/src/wallet/tx_map_and_maybe_trees.rs b/zingolib/src/wallet/tx_map_and_maybe_trees.rs index f96c013ec..98dc9e54e 100644 --- a/zingolib/src/wallet/tx_map_and_maybe_trees.rs +++ b/zingolib/src/wallet/tx_map_and_maybe_trees.rs @@ -47,9 +47,12 @@ impl TxMapAndMaybeTrees { pub mod error { use std::fmt::{Debug, Display, Formatter, Result}; + use crate::wallet::transaction_records_by_id::trait_inputsource::error::InputSourceError; + #[derive(Debug, PartialEq)] pub enum TxMapAndMaybeTreesError { NoSpendCapability, + InputSource(InputSourceError), } impl From<&TxMapAndMaybeTreesError> for String { @@ -59,6 +62,7 @@ pub mod error { NoSpendCapability => { "No witness trees. This is viewkey watch, not a spendkey wallet.".to_string() } + InputSource(e) => e.to_string(), }; format!("{:#?} - {}", value, explanation) } diff --git a/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs index b956c1fe5..938d1ef45 100644 --- a/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs +++ b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs @@ -1,29 +1,19 @@ //! this mod brings input source functionality from transaction_records_by_id - - use zcash_client_backend::{ data_api::{InputSource, SpendableNotes}, + wallet::NoteId, }; - - -use crate::{ - error::{ZingoLibError}, - wallet::{ - notes::{ShNoteId}, - }, -}; - -use super::TxMapAndMaybeTrees; +use super::{error::TxMapAndMaybeTreesError, TxMapAndMaybeTrees}; /// A trait representing the capability to query a data store for unspent transaction outputs belonging to a wallet. /// combining this with WalletRead unlocks propose_transaction /// all implementations in this file redirect to transaction_records_by_id impl InputSource for TxMapAndMaybeTrees { - type Error = ZingoLibError; + type Error = TxMapAndMaybeTreesError; type AccountId = zcash_primitives::zip32::AccountId; - type NoteRef = ShNoteId; + type NoteRef = NoteId; fn get_spendable_note( &self, @@ -41,6 +31,7 @@ impl InputSource for TxMapAndMaybeTrees { > { self.transaction_records_by_id .get_spendable_note(txid, protocol, index) + .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) } fn select_spendable_notes( @@ -50,14 +41,10 @@ impl InputSource for TxMapAndMaybeTrees { sources: &[zcash_client_backend::ShieldedProtocol], anchor_height: zcash_primitives::consensus::BlockHeight, exclude: &[Self::NoteRef], - ) -> Result, ZingoLibError> { - self.transaction_records_by_id.select_spendable_notes( - account, - target_value, - sources, - anchor_height, - exclude, - ) + ) -> Result, Self::Error> { + self.transaction_records_by_id + .select_spendable_notes(account, target_value, sources, anchor_height, exclude) + .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) } fn get_unspent_transparent_output( @@ -66,6 +53,7 @@ impl InputSource for TxMapAndMaybeTrees { ) -> Result, Self::Error> { self.transaction_records_by_id .get_unspent_transparent_output(outpoint) + .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) } fn get_unspent_transparent_outputs( @@ -76,5 +64,6 @@ impl InputSource for TxMapAndMaybeTrees { ) -> Result, Self::Error> { self.transaction_records_by_id .get_unspent_transparent_outputs(address, max_height, exclude) + .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) } } From 96c09398aad5993faab28d8f85c5581e71b50b05 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Fri, 26 Apr 2024 18:17:42 +0000 Subject: [PATCH 5/7] propose compiles --- zingolib/src/lightclient/send.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/zingolib/src/lightclient/send.rs b/zingolib/src/lightclient/send.rs index 5b0213f6e..0da6b9abf 100644 --- a/zingolib/src/lightclient/send.rs +++ b/zingolib/src/lightclient/send.rs @@ -1,5 +1,5 @@ //! TODO: Add Mod Description Here! -use std::num::NonZeroU32; +use std::{num::NonZeroU32, ops::DerefMut}; use log::debug; @@ -68,7 +68,8 @@ impl LightClient { &self, receivers: Vec<(Address, NonNegativeAmount, Option)>, ) -> Result { - let request = receivers_becomes_transaction_request(receivers)?; + let request = + receivers_becomes_transaction_request(receivers).map_err(|e| e.to_string())?; let change_strategy = zcash_client_backend::fees::zip317::SingleOutputChangeStrategy::new( zcash_primitives::transaction::fees::zip317::FeeRule::standard(), @@ -81,7 +82,7 @@ impl LightClient { zcash_client_backend::fees::DustOutputPolicy::default(), ); - let tmamt = self + let mut tmamt = self .wallet .transaction_context .transaction_metadata_set @@ -94,14 +95,14 @@ impl LightClient { GISKit, ZingoLibError, >( - &mut tmamt, + tmamt.deref_mut(), &self.wallet.transaction_context.config.chain, zcash_primitives::zip32::AccountId::ZERO, &input_selector, request, NonZeroU32::new(1).expect("yeep yop"), //review! be more specific ) - .map_err(|e| ZingoLibError::Error(format!("{}", e)))?; + .map_err(|e| ZingoLibError::Error(format!("error this function todo")))?; let mut latest_proposal_lock = self.latest_proposal.write().await; *latest_proposal_lock = Some(crate::data::proposal::ZingoProposal::Transfer( From c242eb9f7afe8c8cb06b285cdf1249ebb7ab790f Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 29 Apr 2024 15:24:04 +0000 Subject: [PATCH 6/7] refeature-gated fixed headers linted clippy --- zingolib/src/data.rs | 2 +- zingolib/src/lightclient.rs | 6 ++-- zingolib/src/lightclient/send.rs | 28 +++++++++---------- .../trait_stub_inputsource.rs | 8 +++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/zingolib/src/data.rs b/zingolib/src/data.rs index cbf2c2622..bb7b728e6 100644 --- a/zingolib/src/data.rs +++ b/zingolib/src/data.rs @@ -1,4 +1,4 @@ //! This is a mod for data structs that will be used across all sections of zingolib. -// #[cfg(feature = "zip317")] +#[cfg(feature = "zip317")] pub mod proposal; pub mod witness_trees; diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index 3bbec0365..8eb59646b 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -19,7 +19,7 @@ use crate::{ wallet::{keys::unified::ReceiverSelection, message::Message, LightWallet, SendProgress}, }; -// #[cfg(feature = "zip317")] +#[cfg(feature = "zip317")] use crate::data::proposal::ZingoProposal; /// TODO: Add Doc Comment Here! @@ -235,7 +235,7 @@ pub struct LightClient { bsync_data: Arc>, interrupt_sync: Arc>, - // #[cfg(feature = "zip317")] + #[cfg(feature = "zip317")] latest_proposal: Arc>>, save_buffer: ZingoSaveBuffer, @@ -278,7 +278,7 @@ pub mod instantiation { sync_lock: Mutex::new(()), bsync_data: Arc::new(RwLock::new(BlazeSyncData::new(&config))), interrupt_sync: Arc::new(RwLock::new(false)), - // #[cfg(feature = "zip317")] + #[cfg(feature = "zip317")] latest_proposal: Arc::new(RwLock::new(None)), save_buffer: ZingoSaveBuffer::new(buffer), }) diff --git a/zingolib/src/lightclient/send.rs b/zingolib/src/lightclient/send.rs index 0da6b9abf..eb532e060 100644 --- a/zingolib/src/lightclient/send.rs +++ b/zingolib/src/lightclient/send.rs @@ -1,13 +1,9 @@ //! TODO: Add Mod Description Here! -use std::{num::NonZeroU32, ops::DerefMut}; - use log::debug; use zcash_client_backend::{ address::Address, - data_api::wallet::input_selection::GreedyInputSelector, zip321::{Payment, TransactionRequest}, - ShieldedProtocol, }; use zcash_primitives::{ consensus::BlockHeight, @@ -15,18 +11,22 @@ use zcash_primitives::{ transaction::{components::amount::NonNegativeAmount, fees::zip317::MINIMUM_FEE}, }; use zcash_proofs::prover::LocalTxProver; -use zingoconfig::ChainType; use super::{LightClient, LightWalletSendProgress}; -use crate::{ - error::ZingoLibError, - utils::zatoshis_from_u64, - wallet::{tx_map_and_maybe_trees::TxMapAndMaybeTrees, Pool}, -}; +use crate::{utils::zatoshis_from_u64, wallet::Pool}; -// #[cfg(feature = "zip317")] -use zcash_primitives::transaction::TxId; +#[cfg(feature = "zip317")] +use { + crate::{error::ZingoLibError, wallet::tx_map_and_maybe_trees::TxMapAndMaybeTrees}, + std::{num::NonZeroU32, ops::DerefMut}, + zcash_client_backend::{ + data_api::wallet::input_selection::GreedyInputSelector, ShieldedProtocol, + }, + zcash_primitives::transaction::TxId, + zingoconfig::ChainType, +}; +#[cfg(feature = "zip317")] type GISKit = GreedyInputSelector< TxMapAndMaybeTrees, zcash_client_backend::fees::zip317::SingleOutputChangeStrategy, @@ -63,7 +63,7 @@ impl LightClient { /// Unstable function to expose the zip317 interface for development // TOdo: add correct functionality and doc comments / tests // TODO: Add migrate_sapling_to_orchard argument - // #[cfg(feature = "zip317")] + #[cfg(feature = "zip317")] pub async fn do_propose_spend( &self, receivers: Vec<(Address, NonNegativeAmount, Option)>, @@ -102,7 +102,7 @@ impl LightClient { request, NonZeroU32::new(1).expect("yeep yop"), //review! be more specific ) - .map_err(|e| ZingoLibError::Error(format!("error this function todo")))?; + .map_err(|e| ZingoLibError::Error(format!("error this function todo error {:?}", e)))?; let mut latest_proposal_lock = self.latest_proposal.write().await; *latest_proposal_lock = Some(crate::data::proposal::ZingoProposal::Transfer( diff --git a/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs index 938d1ef45..810d0c8b9 100644 --- a/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs +++ b/zingolib/src/wallet/tx_map_and_maybe_trees/trait_stub_inputsource.rs @@ -31,7 +31,7 @@ impl InputSource for TxMapAndMaybeTrees { > { self.transaction_records_by_id .get_spendable_note(txid, protocol, index) - .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) + .map_err(TxMapAndMaybeTreesError::InputSource) } fn select_spendable_notes( @@ -44,7 +44,7 @@ impl InputSource for TxMapAndMaybeTrees { ) -> Result, Self::Error> { self.transaction_records_by_id .select_spendable_notes(account, target_value, sources, anchor_height, exclude) - .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) + .map_err(TxMapAndMaybeTreesError::InputSource) } fn get_unspent_transparent_output( @@ -53,7 +53,7 @@ impl InputSource for TxMapAndMaybeTrees { ) -> Result, Self::Error> { self.transaction_records_by_id .get_unspent_transparent_output(outpoint) - .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) + .map_err(TxMapAndMaybeTreesError::InputSource) } fn get_unspent_transparent_outputs( @@ -64,6 +64,6 @@ impl InputSource for TxMapAndMaybeTrees { ) -> Result, Self::Error> { self.transaction_records_by_id .get_unspent_transparent_outputs(address, max_height, exclude) - .map_err(|e| TxMapAndMaybeTreesError::InputSource(e)) + .map_err(TxMapAndMaybeTreesError::InputSource) } } From 739f755cc25d9e64d535e8c42439fb4012949216 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 29 Apr 2024 16:36:08 +0000 Subject: [PATCH 7/7] review: used constant --- zingolib/src/lightclient/send.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zingolib/src/lightclient/send.rs b/zingolib/src/lightclient/send.rs index eb532e060..065b415a2 100644 --- a/zingolib/src/lightclient/send.rs +++ b/zingolib/src/lightclient/send.rs @@ -100,7 +100,7 @@ impl LightClient { zcash_primitives::zip32::AccountId::ZERO, &input_selector, request, - NonZeroU32::new(1).expect("yeep yop"), //review! be more specific + NonZeroU32::MIN, //review! use custom constant? ) .map_err(|e| ZingoLibError::Error(format!("error this function todo error {:?}", e)))?;