1- use std:: collections:: BTreeMap ;
2- use std:: convert:: Infallible ;
31use std:: num:: { NonZeroU32 , NonZeroUsize } ;
42
53use bip0039:: { English , Mnemonic } ;
@@ -16,13 +14,12 @@ use webzjs_common::Network;
1614
1715use pczt:: roles:: combiner:: Combiner ;
1816use pczt:: roles:: prover:: Prover ;
19- use pczt :: roles :: signer :: Signer ;
17+
2018use pczt:: roles:: updater:: Updater ;
21- use pczt:: roles:: verifier:: Verifier ;
2219use pczt:: Pczt ;
2320use sapling:: ProofGenerationKey ;
2421use serde:: de:: DeserializeOwned ;
25- use serde:: { Deserialize , Serialize , Serializer } ;
22+ use serde:: Serialize ;
2623use std:: fmt:: Debug ;
2724use std:: hash:: Hash ;
2825use std:: sync:: Arc ;
@@ -39,32 +36,33 @@ use zcash_client_backend::data_api::{
3936} ;
4037use zcash_client_backend:: data_api:: { WalletCommitmentTrees , Zip32Derivation } ;
4138use zcash_client_backend:: fees:: standard:: MultiOutputChangeStrategy ;
42- use zcash_client_backend:: fees:: zip317:: SingleOutputChangeStrategy ;
4339use zcash_client_backend:: fees:: { DustOutputPolicy , SplitPolicy , StandardFeeRule } ;
4440use zcash_client_backend:: proposal:: Proposal ;
4541use zcash_client_backend:: proto:: service:: {
4642 self , compact_tx_streamer_client:: CompactTxStreamerClient ,
4743} ;
4844use zcash_client_backend:: wallet:: OvkPolicy ;
4945use zcash_client_backend:: zip321:: { Payment , TransactionRequest } ;
50- use zcash_client_backend:: ShieldedProtocol ;
5146use zcash_client_memory:: { MemBlockCache , MemoryWalletDb } ;
5247use zcash_keys:: keys:: { UnifiedFullViewingKey , UnifiedSpendingKey } ;
53- use zcash_primitives:: transaction:: components:: amount:: NonNegativeAmount ;
5448use zcash_primitives:: transaction:: fees:: FeeRule ;
5549use zcash_primitives:: transaction:: TxId ;
5650use zcash_proofs:: prover:: LocalTxProver ;
51+ use zcash_protocol:: ShieldedProtocol ;
5752
58- use crate :: error:: Error :: PcztCreate ;
5953use zcash_client_backend:: sync:: run;
60- use zcash_primitives:: legacy:: keys:: { NonHardenedChildIndex , TransparentKeyScope } ;
61- use zcash_primitives:: zip32;
62- use zcash_primitives:: zip32:: fingerprint:: SeedFingerprint ;
63- use zcash_protocol:: consensus:: { NetworkConstants , Parameters } ;
54+
55+ use zcash_protocol:: consensus:: Parameters ;
6456use zcash_protocol:: value:: Zatoshis ;
57+ use zip32;
58+ use zip32:: fingerprint:: SeedFingerprint ;
6559
6660const BATCH_SIZE : u32 = 10000 ;
6761
62+ /// constant that signals what's the minimum transparent balance for proposing a
63+ /// shielding transaction
64+ const SHIELDING_THRESHOLD : Zatoshis = Zatoshis :: const_from_u64 ( 100000 ) ;
65+
6866/// # A Zcash wallet
6967///
7068/// A wallet is a set of accounts that can be synchronized together with the blockchain.
@@ -323,7 +321,7 @@ where
323321 ) ;
324322 let request = TransactionRequest :: new ( vec ! [ Payment :: without_memo(
325323 to_address,
326- NonNegativeAmount :: from_u64( value) ?,
324+ Zatoshis :: from_u64( value) ?,
327325 ) ] ) ?;
328326
329327 tracing:: info!( "Chain height: {:?}" , self . db. read( ) . await . chain_height( ) ?) ;
@@ -469,10 +467,10 @@ where
469467 & self . network ,
470468 & input_selector,
471469 & change_strategy,
472- Zatoshis :: ZERO ,
470+ SHIELDING_THRESHOLD , // use a shielding threshold above a marginal fee transaction plus some value like Zashi does.
473471 & from_addrs,
474472 account_id,
475- 0 ,
473+ 1 , // librustzcash operates under the assumption of zero or one conf being the same but that could change.
476474 )
477475 . map_err ( |e| Error :: Generic ( format ! ( "Error when shielding: {:?}" , e) ) ) ?;
478476
@@ -519,7 +517,7 @@ where
519517 let input_selector = GreedyInputSelector :: new ( ) ;
520518 let request = TransactionRequest :: new ( vec ! [ Payment :: without_memo(
521519 to_address,
522- NonNegativeAmount :: from_u64( value) ?,
520+ Zatoshis :: from_u64( value) ?,
523521 ) ] ) ?;
524522 let mut db = self . db . write ( ) . await ;
525523 let proposal = propose_transfer :: < _ , _ , _ , _ , <W as WalletCommitmentTrees >:: Error > (
@@ -583,7 +581,7 @@ where
583581 . collect :: < Vec < _ > > ( ) ;
584582
585583 // Assume all non-dummy spent notes are from the same account.
586- for ( index, derivation ) in non_dummy_spends {
584+ for ( index, _ ) in non_dummy_spends {
587585 updater. update_spend_with ( index, |mut spend_updater| {
588586 spend_updater. set_proof_generation_key ( sapling_proof_gen_key. clone ( ) )
589587 } ) ?;
0 commit comments