From 84469ad71a3f389aaf839e2d4c40e612fa8b64a0 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Wed, 1 May 2024 16:41:25 +0000 Subject: [PATCH 1/4] impl std::fmt::Display for NoteId --- zcash_client_backend/src/wallet.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zcash_client_backend/src/wallet.rs b/zcash_client_backend/src/wallet.rs index 418bb3e3a1..a822b5e829 100644 --- a/zcash_client_backend/src/wallet.rs +++ b/zcash_client_backend/src/wallet.rs @@ -1,6 +1,8 @@ //! Structs representing transaction data scanned from the block chain by a wallet or //! light client. +use std::fmt; + use incrementalmerkletree::Position; use zcash_keys::address::Address; use zcash_note_encryption::EphemeralKeyBytes; @@ -62,6 +64,18 @@ impl NoteId { } } +impl fmt::Display for NoteId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "txid {} protocol {:?} output_index {}", + self.txid(), + self.protocol(), + self.output_index() + ) + } +} + /// A type that represents the recipient of a transaction output: a recipient address (and, for /// unified addresses, the pool to which the payment is sent) in the case of an outgoing output, or an /// internal account ID and the pool to which funds were sent in the case of a wallet-internal From 239c894b1572be4be2c7aace87c3afac08889620 Mon Sep 17 00:00:00 2001 From: Hazel OHearn Date: Wed, 15 May 2024 12:45:23 -0300 Subject: [PATCH 2/4] add extra method for non-traditional tkey derevation --- zcash_client_backend/src/data_api/wallet.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/zcash_client_backend/src/data_api/wallet.rs b/zcash_client_backend/src/data_api/wallet.rs index 87629c14e6..de5f876d10 100644 --- a/zcash_client_backend/src/data_api/wallet.rs +++ b/zcash_client_backend/src/data_api/wallet.rs @@ -52,7 +52,7 @@ use crate::{ fees::{self, DustOutputPolicy}, keys::UnifiedSpendingKey, proposal::{self, Proposal, ProposalError}, - wallet::{Note, OvkPolicy, Recipient}, + wallet::{Note, OvkPolicy, Recipient, TransparentAddressMetadata}, zip321::{self, Payment}, PoolType, ShieldedProtocol, }; @@ -619,6 +619,7 @@ where proposal.min_target_height(), &step_results, step, + None, )?; step_results.push((step, step_result)); } @@ -646,6 +647,9 @@ pub fn calculate_proposed_transaction( min_target_height: BlockHeight, prior_step_results: &[(&proposal::Step, BuildResult)], proposal_step: &proposal::Step, + usk_to_tkey: Option< + fn(&UnifiedSpendingKey, &TransparentAddressMetadata) -> hdwallet::secp256k1::SecretKey, + >, ) -> Result< BuildResult, Error< @@ -824,10 +828,16 @@ where .clone() .ok_or_else(|| Error::NoSpendingKey(addr.encode(params)))?; - let secret_key = usk - .transparent() - .derive_secret_key(address_metadata.scope(), address_metadata.address_index()) - .unwrap(); + let secret_key = usk_to_tkey + .map(|f| f(usk, &address_metadata)) + .unwrap_or_else(|| { + usk.transparent() + .derive_secret_key( + address_metadata.scope(), + address_metadata.address_index(), + ) + .unwrap() + }); utxos_spent.push(outpoint.clone()); builder.add_transparent_input(secret_key, outpoint, utxo)?; From 471a062dcd5b55a3f57b4861453c080eeae88f22 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Thu, 30 May 2024 18:46:48 +0000 Subject: [PATCH 3/4] create 0-value change --- zcash_client_backend/src/fees/common.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/zcash_client_backend/src/fees/common.rs b/zcash_client_backend/src/fees/common.rs index a8a791a527..49b15caace 100644 --- a/zcash_client_backend/src/fees/common.rs +++ b/zcash_client_backend/src/fees/common.rs @@ -203,7 +203,15 @@ where })?; if proposed_change.is_zero() { - TransactionBalance::new(vec![], fee_amount).map_err(|_| overflow()) + TransactionBalance::new( + vec![ChangeValue::new( + _fallback_change_pool, + NonNegativeAmount::const_from_u64(0), + change_memo, + )], + fee_amount, + ) + .map_err(|_| overflow()) } else { let dust_threshold = dust_output_policy .dust_threshold() From c2962db62d686962b7679749dec0c6380d5b4858 Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Mon, 17 Jun 2024 16:05:06 +0000 Subject: [PATCH 4/4] update changelog --- zcash_client_backend/CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zcash_client_backend/CHANGELOG.md b/zcash_client_backend/CHANGELOG.md index 009c79ea2b..c776acbcd2 100644 --- a/zcash_client_backend/CHANGELOG.md +++ b/zcash_client_backend/CHANGELOG.md @@ -5,7 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this library adheres to Rust's notion of [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [Zingo] +- replace create_proposed_transaction with `calculate_proposed_transaction` + - dont try to write the calculated transaction to wallet, that will be handled later + - ignore collecting any transaction metadata + - handle usk differently +- modify change algorithm +- added display for NoteId ## [0.12.1] - 2024-03-27