From b6e29d0f488b4e45e4e12d111722e25e13526913 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Wed, 18 Sep 2024 20:20:34 +0000 Subject: [PATCH 1/4] ignored aborted_resync test after discussion about its relevance --- libtonode-tests/tests/concrete.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libtonode-tests/tests/concrete.rs b/libtonode-tests/tests/concrete.rs index 995051951..febdbe5e3 100644 --- a/libtonode-tests/tests/concrete.rs +++ b/libtonode-tests/tests/concrete.rs @@ -3321,6 +3321,7 @@ mod slow { assert_eq!(orchard_note.value(), 0); } #[tokio::test] + #[ignore = "test does not correspond to real-world case"] async fn aborted_resync() { let (regtest_manager, _cph, faucet, recipient, _txid) = scenarios::orchard_funded_recipient(500_000).await; From 9125feea67f5e845fd4f0e44cc38ba1cb382abea Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Thu, 19 Sep 2024 18:22:10 +0100 Subject: [PATCH 2/4] implement spendable t outputs and fix errors with usk to tkey override --- Cargo.lock | 38 ++++++-------- Cargo.toml | 23 ++++++--- zingolib/Cargo.toml | 1 - zingolib/src/wallet/send.rs | 18 ------- .../trait_inputsource.rs | 50 +++++++++++++++++-- .../wallet/tx_map/trait_stub_inputsource.rs | 11 ++++ 6 files changed, 85 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e3c428ba..cdcd84ae4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -340,7 +340,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.12.1", + "itertools", "lazy_static", "lazycell", "log", @@ -925,7 +925,7 @@ dependencies = [ [[package]] name = "equihash" version = "0.2.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "blake2b_simd", "byteorder", @@ -960,7 +960,7 @@ dependencies = [ [[package]] name = "f4jumble" version = "0.1.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "blake2b_simd", ] @@ -1577,15 +1577,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -1693,7 +1684,7 @@ dependencies = [ "bip0039", "hex", "http", - "itertools 0.10.5", + "itertools", "json", "log", "orchard", @@ -2318,7 +2309,7 @@ checksum = "f8650aabb6c35b860610e9cff5dc1af886c9e25073b7b1712a68972af4281302" dependencies = [ "bytes 1.6.0", "heck", - "itertools 0.12.1", + "itertools", "log", "multimap", "once_cell", @@ -2338,7 +2329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools", "proc-macro2", "quote", "syn 2.0.68", @@ -4052,7 +4043,7 @@ checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "zcash_address" version = "0.4.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "bech32", "bs58", @@ -4064,7 +4055,7 @@ dependencies = [ [[package]] name = "zcash_client_backend" version = "0.13.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "base64 0.21.7", "bech32", @@ -4109,7 +4100,7 @@ dependencies = [ [[package]] name = "zcash_encoding" version = "0.2.1" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "byteorder", "nonempty", @@ -4118,7 +4109,7 @@ dependencies = [ [[package]] name = "zcash_keys" version = "0.3.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "bech32", "bip32", @@ -4159,7 +4150,7 @@ dependencies = [ [[package]] name = "zcash_primitives" version = "0.16.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "aes", "bip32", @@ -4197,7 +4188,7 @@ dependencies = [ [[package]] name = "zcash_proofs" version = "0.16.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "bellman", "blake2b_simd", @@ -4219,7 +4210,7 @@ dependencies = [ [[package]] name = "zcash_protocol" version = "0.2.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "document-features", "memuse", @@ -4348,7 +4339,6 @@ dependencies = [ "futures", "getset", "group", - "hdwallet", "hex", "http", "incrementalmerkletree", @@ -4410,7 +4400,7 @@ dependencies = [ [[package]] name = "zip321" version = "0.1.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5#7ad60b5d50b3743d3c7235bd7684ff47c8402e7f" +source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" dependencies = [ "base64 0.21.7", "nom", diff --git a/Cargo.toml b/Cargo.toml index c9908b028..67e668f2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,14 +22,22 @@ shardtree = "0.4" # annotated tag starting with LRZ base tag and ending with `git describe --dirty` # TAG FROM `main_zingolib` BRANCH OF LIBRUSTZCASH FORK! -zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5", features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] } -zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5", features = ["transparent-inputs", "sapling", "orchard" ] } +zcash_address = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } +zcash_client_backend = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib", features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] } +zcash_encoding = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } +zcash_keys = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib", features = ["transparent-inputs", "sapling", "orchard" ] } zcash_note_encryption = "0.4" -zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -zcash_protocol = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } +zcash_primitives = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } +zcash_proofs = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } +zcash_protocol = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } +# zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } +# zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5", features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] } +# zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } +# zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5", features = ["transparent-inputs", "sapling", "orchard" ] } +# zcash_note_encryption = "0.4" +# zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } +# zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } +# zcash_protocol = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } zip32 = "0.1" append-only-vec = { git = "https://github.com/zancas/append-only-vec.git", branch = "add_debug_impl" } @@ -49,7 +57,6 @@ futures = "0.3.15" futures-util = "0.3.28" getset = "0.1.2" group = "0.13" -hdwallet = { git = "https://github.com/fluidvanadium/hdwallet.git", tag = "update_secp256k1_to_0.27.0" } hex = "0.4" http = "1.1.0" http-body-util = "0.1.2" diff --git a/zingolib/Cargo.toml b/zingolib/Cargo.toml index 59e234210..2fc13a305 100644 --- a/zingolib/Cargo.toml +++ b/zingolib/Cargo.toml @@ -50,7 +50,6 @@ ff = { workspace = true } futures = { workspace = true } getset = { workspace = true } group = { workspace = true } -hdwallet = { workspace = true } hex = { workspace = true } http.workspace = true indoc = { workspace = true } diff --git a/zingolib/src/wallet/send.rs b/zingolib/src/wallet/send.rs index 9f75eecd6..e0ba06a98 100644 --- a/zingolib/src/wallet/send.rs +++ b/zingolib/src/wallet/send.rs @@ -1,6 +1,5 @@ //! This mod contains pieces of the impl LightWallet that are invoked during a send. -use hdwallet::traits::Deserialize as _; use log::error; use zcash_client_backend::proposal::Proposal; use zcash_keys::keys::UnifiedSpendingKey; @@ -149,22 +148,6 @@ impl LightWallet { return Err(BuildTransactionError::ExchangeAddressesNotSupported); } - // The 'UnifiedSpendingKey' we create is not a 'proper' USK, in that the - // transparent key it contains is not the account spending key, but the - // externally-scoped derivative key. The goal is to fix this, but in the - // interim we use this special-case logic. - fn usk_to_tkey( - unified_spend_key: &UnifiedSpendingKey, - t_metadata: &zcash_client_backend::wallet::TransparentAddressMetadata, - ) -> secp256k1::SecretKey { - hdwallet::ExtendedPrivKey::deserialize(&unified_spend_key.transparent().to_bytes()) - .expect("This a hack to do a type conversion, and will not fail") - .derive_private_key(t_metadata.address_index().index().into()) - // This is unwrapped in librustzcash, so I'm not too worried about it - .expect("private key derivation failed") - .private_key - } - zcash_client_backend::data_api::wallet::create_proposed_transactions( self.transaction_context .transaction_metadata_set @@ -177,7 +160,6 @@ impl LightWallet { &unified_spend_key, zcash_client_backend::wallet::OvkPolicy::Sender, proposal, - Some(usk_to_tkey), Some(self.wallet_capability().first_sapling_address()), )?; Ok(()) 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 1b99ebc81..85e6e822b 100644 --- a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs +++ b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs @@ -4,16 +4,20 @@ use orchard::note_encryption::OrchardDomain; use sapling_crypto::note_encryption::SaplingDomain; use zcash_client_backend::{ data_api::{InputSource, SpendableNotes}, - wallet::ReceivedNote, + wallet::{ReceivedNote, WalletTransparentOutput}, ShieldedProtocol, }; -use zcash_primitives::transaction::{ - components::amount::NonNegativeAmount, fees::zip317::MARGINAL_FEE, TxId, +use zcash_primitives::{ + legacy::Script, + transaction::{ + components::{amount::NonNegativeAmount, TxOut}, + fees::zip317::MARGINAL_FEE, + TxId, + }, }; -use crate::wallet::transaction_records_by_id::TransactionRecordsById; +use crate::wallet::{notes::OutputInterface, transaction_records_by_id::TransactionRecordsById}; -// error type use std::fmt::Debug; use thiserror::Error; @@ -281,6 +285,42 @@ impl InputSource for TransactionRecordsById { ) -> Result, Self::Error> { unimplemented!() } + + fn get_spendable_transparent_outputs( + &self, + _address: &zcash_primitives::legacy::TransparentAddress, + target_height: zcash_primitives::consensus::BlockHeight, + _min_confirmations: u32, + ) -> Result, Self::Error> { + // TODO: rewrite to include addresses and min confirmations + let transparent_outputs: Vec = self + .values() + .filter(|tx| { + tx.status + .get_confirmed_height() + .map_or(false, |height| height <= target_height) + }) + .flat_map(|tx| { + tx.transparent_outputs().iter().filter_map(|output| { + if output.spending_tx_status().is_none() { + WalletTransparentOutput::from_parts( + output.to_outpoint(), + TxOut { + value: NonNegativeAmount::from_u64(output.value()) + .expect("value should be in valid range of zatoshis"), + script_pubkey: Script(output.script.clone()), + }, + Some(tx.status.get_height()), + ) + } else { + None + } + }) + }) + .collect(); + + Ok(transparent_outputs) + } } #[cfg(test)] diff --git a/zingolib/src/wallet/tx_map/trait_stub_inputsource.rs b/zingolib/src/wallet/tx_map/trait_stub_inputsource.rs index 93e66b469..8dda51e1e 100644 --- a/zingolib/src/wallet/tx_map/trait_stub_inputsource.rs +++ b/zingolib/src/wallet/tx_map/trait_stub_inputsource.rs @@ -51,4 +51,15 @@ impl InputSource for TxMap { ) -> Result, Self::Error> { unimplemented!() } + + fn get_spendable_transparent_outputs( + &self, + _address: &zcash_primitives::legacy::TransparentAddress, + target_height: zcash_primitives::consensus::BlockHeight, + _min_confirmations: u32, + ) -> Result, Self::Error> { + self.transaction_records_by_id + .get_spendable_transparent_outputs(_address, target_height, _min_confirmations) + .map_err(TxMapTraitError::InputSource) + } } From bc5de6f36f9c377228f459673904273acca1b2ed Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Thu, 19 Sep 2024 19:12:54 +0100 Subject: [PATCH 3/4] adjusted balance and note selection to account for 5000 zat note being dust --- Cargo.lock | 33 ++++++------------- Cargo.toml | 22 ++++--------- zingolib/src/wallet/describe.rs | 2 +- zingolib/src/wallet/send.rs | 2 +- .../trait_inputsource.rs | 3 +- 5 files changed, 21 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdcd84ae4..5af92ec3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -925,7 +925,7 @@ dependencies = [ [[package]] name = "equihash" version = "0.2.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "blake2b_simd", "byteorder", @@ -960,7 +960,7 @@ dependencies = [ [[package]] name = "f4jumble" version = "0.1.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "blake2b_simd", ] @@ -1278,18 +1278,6 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -[[package]] -name = "hdwallet" -version = "0.4.2" -source = "git+https://github.com/fluidvanadium/hdwallet.git?tag=update_secp256k1_to_0.27.0#fca2d8f5d93bfd4801a1ec5ba96f7a02d4c12eb7" -dependencies = [ - "lazy_static", - "rand_core 0.6.4", - "ring 0.16.20", - "secp256k1", - "thiserror", -] - [[package]] name = "heck" version = "0.5.0" @@ -4043,7 +4031,7 @@ checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "zcash_address" version = "0.4.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "bech32", "bs58", @@ -4055,7 +4043,7 @@ dependencies = [ [[package]] name = "zcash_client_backend" version = "0.13.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "base64 0.21.7", "bech32", @@ -4066,7 +4054,6 @@ dependencies = [ "crossbeam-channel", "document-features", "group", - "hdwallet", "hex", "hyper-util", "incrementalmerkletree", @@ -4100,7 +4087,7 @@ dependencies = [ [[package]] name = "zcash_encoding" version = "0.2.1" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "byteorder", "nonempty", @@ -4109,7 +4096,7 @@ dependencies = [ [[package]] name = "zcash_keys" version = "0.3.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "bech32", "bip32", @@ -4150,7 +4137,7 @@ dependencies = [ [[package]] name = "zcash_primitives" version = "0.16.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "aes", "bip32", @@ -4188,7 +4175,7 @@ dependencies = [ [[package]] name = "zcash_proofs" version = "0.16.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "bellman", "blake2b_simd", @@ -4210,7 +4197,7 @@ dependencies = [ [[package]] name = "zcash_protocol" version = "0.2.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "document-features", "memuse", @@ -4400,7 +4387,7 @@ dependencies = [ [[package]] name = "zip321" version = "0.1.0" -source = "git+https://github.com/Oscar-Pepper/librustzcash.git?branch=main_zingolib#5822ef0da98cd4b90a8937f6070ac3b11dcff3c6" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08#121371a089f076a5ee2737809c792d905f5a4b3a" dependencies = [ "base64 0.21.7", "nom", diff --git a/Cargo.toml b/Cargo.toml index 67e668f2e..8267262c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,22 +22,14 @@ shardtree = "0.4" # annotated tag starting with LRZ base tag and ending with `git describe --dirty` # TAG FROM `main_zingolib` BRANCH OF LIBRUSTZCASH FORK! -zcash_address = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } -zcash_client_backend = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib", features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] } -zcash_encoding = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } -zcash_keys = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib", features = ["transparent-inputs", "sapling", "orchard" ] } +zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08" } +zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08" , features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] } +zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08" } +zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08" , features = ["transparent-inputs", "sapling", "orchard" ] } zcash_note_encryption = "0.4" -zcash_primitives = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } -zcash_proofs = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } -zcash_protocol = { git = "https://github.com/Oscar-Pepper/librustzcash.git", branch = "main_zingolib" } -# zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -# zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5", features = ["lightwalletd-tonic", "orchard", "transparent-inputs"] } -# zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -# zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5", features = ["transparent-inputs", "sapling", "orchard" ] } -# zcash_note_encryption = "0.4" -# zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -# zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } -# zcash_protocol = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5" } +zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08" } +zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08" } +zcash_protocol = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_client_sqlite-0.11.2_plus_zingolabs_changes-1-g7ad60b5d5-2-g121371a08" } zip32 = "0.1" append-only-vec = { git = "https://github.com/zancas/append-only-vec.git", branch = "add_debug_impl" } diff --git a/zingolib/src/wallet/describe.rs b/zingolib/src/wallet/describe.rs index d3bf6c0b4..15442790b 100644 --- a/zingolib/src/wallet/describe.rs +++ b/zingolib/src/wallet/describe.rs @@ -155,7 +155,7 @@ impl LightWallet { Box::new(|note, transaction| { transaction.status.is_confirmed() && !note.pending_receipt() - && note.value() >= MARGINAL_FEE.into_u64() + && note.value() > MARGINAL_FEE.into_u64() }); self.get_filtered_balance::(filter_function).await } diff --git a/zingolib/src/wallet/send.rs b/zingolib/src/wallet/send.rs index e0ba06a98..8c5670d28 100644 --- a/zingolib/src/wallet/send.rs +++ b/zingolib/src/wallet/send.rs @@ -141,7 +141,7 @@ impl LightWallet { self.mnemonic().unwrap().0.to_seed("").as_slice(), zip32::AccountId::ZERO, ) - .map_err(|e| BuildTransactionError::UnifiedSpendKey(e))?; + .map_err(BuildTransactionError::UnifiedSpendKey)?; // We don't support zip320 yet. Only one step. if proposal.steps().len() != 1 { 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 85e6e822b..7bd99680c 100644 --- a/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs +++ b/zingolib/src/wallet/transaction_records_by_id/trait_inputsource.rs @@ -175,7 +175,8 @@ impl InputSource for TransactionRecordsById { .collect::, _>>() .map_err(InputSourceError::InvalidValue)?; unselected.sort_by_key(|(_id, value)| *value); // from smallest to largest - let dust_spendable_index = unselected.partition_point(|(_id, value)| *value < MARGINAL_FEE); + let dust_spendable_index = + unselected.partition_point(|(_id, value)| *value <= MARGINAL_FEE); let _dust_notes: Vec<_> = unselected.drain(..dust_spendable_index).collect(); let mut selected = vec![]; let mut index_of_unselected = 0; From 8fe72be374183154984e58b3498bc26012fe6385 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Thu, 19 Sep 2024 20:06:19 +0100 Subject: [PATCH 4/4] fix confirmed_balance_excluding_dust test --- zingolib/src/wallet/describe.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zingolib/src/wallet/describe.rs b/zingolib/src/wallet/describe.rs index 15442790b..1c94e9853 100644 --- a/zingolib/src/wallet/describe.rs +++ b/zingolib/src/wallet/describe.rs @@ -352,7 +352,7 @@ mod tests { OrchardNoteBuilder::default() .note( OrchardCryptoNoteBuilder::default() - .value(orchard::value::NoteValue::from_raw(5_000)) + .value(orchard::value::NoteValue::from_raw(5_001)) .clone(), ) .clone(), @@ -397,7 +397,7 @@ mod tests { wallet .confirmed_balance_excluding_dust::() .await, - Some(1_605_000) + Some(1_605_001) ); } }