zcash_client_backend: Improve type safety of `get_known_ephemeral_addresses`
This commit is contained in:
parent
5290d13942
commit
29d8f10cdc
|
@ -166,6 +166,7 @@ lightwalletd-tonic-transport = ["lightwalletd-tonic", "tonic?/transport"]
|
|||
## Enables receiving transparent funds and shielding them.
|
||||
transparent-inputs = [
|
||||
"dep:bip32",
|
||||
"transparent/transparent-inputs",
|
||||
"zcash_keys/transparent-inputs",
|
||||
"zcash_primitives/transparent-inputs",
|
||||
]
|
||||
|
|
|
@ -74,15 +74,12 @@ use zcash_keys::{
|
|||
UnifiedAddressRequest, UnifiedFullViewingKey, UnifiedIncomingViewingKey, UnifiedSpendingKey,
|
||||
},
|
||||
};
|
||||
use zcash_primitives::{
|
||||
block::BlockHash,
|
||||
transaction::{Transaction, TxId},
|
||||
};
|
||||
use zcash_primitives::{block::BlockHash, transaction::Transaction};
|
||||
use zcash_protocol::{
|
||||
consensus::BlockHeight,
|
||||
memo::{Memo, MemoBytes},
|
||||
value::{BalanceError, Zatoshis},
|
||||
ShieldedProtocol,
|
||||
ShieldedProtocol, TxId,
|
||||
};
|
||||
use zip32::fingerprint::SeedFingerprint;
|
||||
|
||||
|
@ -99,8 +96,8 @@ use crate::{
|
|||
#[cfg(feature = "transparent-inputs")]
|
||||
use {
|
||||
crate::wallet::TransparentAddressMetadata,
|
||||
::transparent::{address::TransparentAddress, bundle::OutPoint},
|
||||
std::ops::Range,
|
||||
transparent::{address::TransparentAddress, bundle::OutPoint, keys::NonHardenedChildIndex},
|
||||
};
|
||||
|
||||
#[cfg(feature = "test-dependencies")]
|
||||
|
@ -1465,7 +1462,7 @@ pub trait WalletRead {
|
|||
fn get_known_ephemeral_addresses(
|
||||
&self,
|
||||
_account: Self::AccountId,
|
||||
_index_range: Option<Range<u32>>,
|
||||
_index_range: Option<Range<NonHardenedChildIndex>>,
|
||||
) -> Result<Vec<(TransparentAddress, TransparentAddressMetadata)>, Self::Error> {
|
||||
Ok(vec![])
|
||||
}
|
||||
|
|
|
@ -8,11 +8,6 @@ use std::{
|
|||
num::NonZeroU32,
|
||||
};
|
||||
|
||||
use ::sapling::{
|
||||
note_encryption::{sapling_note_encryption, SaplingDomain},
|
||||
util::generate_random_rseed,
|
||||
zip32::DiversifiableFullViewingKey,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use group::ff::Field;
|
||||
use incrementalmerkletree::{Marking, Retention};
|
||||
|
@ -23,6 +18,11 @@ use secrecy::{ExposeSecret, Secret, SecretVec};
|
|||
use shardtree::{error::ShardTreeError, store::memory::MemoryShardStore, ShardTree};
|
||||
use subtle::ConditionallySelectable;
|
||||
|
||||
use ::sapling::{
|
||||
note_encryption::{sapling_note_encryption, SaplingDomain},
|
||||
util::generate_random_rseed,
|
||||
zip32::DiversifiableFullViewingKey,
|
||||
};
|
||||
use zcash_address::ZcashAddress;
|
||||
use zcash_keys::{
|
||||
address::{Address, UnifiedAddress},
|
||||
|
@ -44,6 +44,21 @@ use zcash_protocol::{
|
|||
use zip32::{fingerprint::SeedFingerprint, DiversifierIndex};
|
||||
use zip321::Payment;
|
||||
|
||||
use super::{
|
||||
chain::{scan_cached_blocks, BlockSource, ChainState, CommitmentTreeRoot, ScanSummary},
|
||||
error::Error,
|
||||
scanning::ScanRange,
|
||||
wallet::{
|
||||
create_proposed_transactions,
|
||||
input_selection::{GreedyInputSelector, InputSelector},
|
||||
propose_standard_transfer_to_address, propose_transfer,
|
||||
},
|
||||
Account, AccountBalance, AccountBirthday, AccountMeta, AccountPurpose, AccountSource,
|
||||
BlockMetadata, DecryptedTransaction, InputSource, NoteFilter, NullifierQuery, ScannedBlock,
|
||||
SeedRelevance, SentTransaction, SpendableNotes, TransactionDataRequest, TransactionStatus,
|
||||
WalletCommitmentTrees, WalletRead, WalletSummary, WalletTest, WalletWrite,
|
||||
SAPLING_SHARD_HEIGHT,
|
||||
};
|
||||
use crate::{
|
||||
fees::{
|
||||
standard::{self, SingleOutputChangeStrategy},
|
||||
|
@ -56,26 +71,12 @@ use crate::{
|
|||
wallet::{Note, NoteId, OvkPolicy, ReceivedNote, WalletTransparentOutput},
|
||||
};
|
||||
|
||||
use super::{
|
||||
chain::{scan_cached_blocks, BlockSource, ChainState, CommitmentTreeRoot, ScanSummary},
|
||||
scanning::ScanRange,
|
||||
wallet::{
|
||||
create_proposed_transactions,
|
||||
input_selection::{GreedyInputSelector, InputSelector},
|
||||
propose_standard_transfer_to_address, propose_transfer,
|
||||
},
|
||||
Account, AccountBalance, AccountBirthday, AccountMeta, AccountPurpose, AccountSource,
|
||||
BlockMetadata, DecryptedTransaction, InputSource, NullifierQuery, ScannedBlock, SeedRelevance,
|
||||
SentTransaction, SpendableNotes, TransactionDataRequest, TransactionStatus,
|
||||
WalletCommitmentTrees, WalletRead, WalletSummary, WalletTest, WalletWrite,
|
||||
SAPLING_SHARD_HEIGHT,
|
||||
};
|
||||
use super::{error::Error, NoteFilter};
|
||||
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
use {
|
||||
super::wallet::input_selection::ShieldingSelector, crate::wallet::TransparentAddressMetadata,
|
||||
::transparent::address::TransparentAddress, std::ops::Range,
|
||||
super::wallet::input_selection::ShieldingSelector,
|
||||
crate::wallet::TransparentAddressMetadata,
|
||||
::transparent::{address::TransparentAddress, keys::NonHardenedChildIndex},
|
||||
std::ops::Range,
|
||||
};
|
||||
|
||||
#[cfg(feature = "orchard")]
|
||||
|
@ -2624,7 +2625,7 @@ impl WalletRead for MockWalletDb {
|
|||
fn get_known_ephemeral_addresses(
|
||||
&self,
|
||||
_account: Self::AccountId,
|
||||
_index_range: Option<Range<u32>>,
|
||||
_index_range: Option<Range<NonHardenedChildIndex>>,
|
||||
) -> Result<Vec<(TransparentAddress, TransparentAddressMetadata)>, Self::Error> {
|
||||
Ok(vec![])
|
||||
}
|
||||
|
|
|
@ -827,7 +827,13 @@ pub fn send_multi_step_proposed_transfer<T: ShieldedPoolTester, DSF>(
|
|||
// the start of the gap to index 12. This also tests the `index_range` parameter.
|
||||
let newer_known_addrs = st
|
||||
.wallet()
|
||||
.get_known_ephemeral_addresses(account_id, Some(5..100))
|
||||
.get_known_ephemeral_addresses(
|
||||
account_id,
|
||||
Some(
|
||||
NonHardenedChildIndex::from_index(5).unwrap()
|
||||
..NonHardenedChildIndex::from_index(100).unwrap(),
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(newer_known_addrs.len(), (GAP_LIMIT as usize) + 12 - 5);
|
||||
assert!(newer_known_addrs.starts_with(&new_known_addrs[5..]));
|
||||
|
|
|
@ -123,6 +123,7 @@ test-dependencies = [
|
|||
## Enables receiving transparent funds and sending to transparent recipients
|
||||
transparent-inputs = [
|
||||
"dep:bip32",
|
||||
"transparent/transparent-inputs",
|
||||
"zcash_keys/transparent-inputs",
|
||||
"zcash_client_backend/transparent-inputs"
|
||||
]
|
||||
|
|
|
@ -92,9 +92,9 @@ use {
|
|||
|
||||
#[cfg(feature = "transparent-inputs")]
|
||||
use {
|
||||
::transparent::{address::TransparentAddress, bundle::OutPoint},
|
||||
::transparent::{address::TransparentAddress, bundle::OutPoint, keys::NonHardenedChildIndex},
|
||||
zcash_client_backend::wallet::TransparentAddressMetadata,
|
||||
zcash_keys::encoding::AddressCodec as _,
|
||||
zcash_keys::encoding::AddressCodec,
|
||||
};
|
||||
|
||||
#[cfg(feature = "multicore")]
|
||||
|
@ -659,14 +659,14 @@ impl<C: Borrow<rusqlite::Connection>, P: consensus::Parameters> WalletRead for W
|
|||
fn get_known_ephemeral_addresses(
|
||||
&self,
|
||||
account: Self::AccountId,
|
||||
index_range: Option<Range<u32>>,
|
||||
index_range: Option<Range<NonHardenedChildIndex>>,
|
||||
) -> Result<Vec<(TransparentAddress, TransparentAddressMetadata)>, Self::Error> {
|
||||
let account_id = wallet::get_account_ref(self.conn.borrow(), account)?;
|
||||
wallet::transparent::ephemeral::get_known_ephemeral_addresses(
|
||||
self.conn.borrow(),
|
||||
&self.params,
|
||||
account_id,
|
||||
index_range,
|
||||
index_range.map(|i| i.start.index()..i.end.index()),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ use crate::{
|
|||
#[cfg(feature = "transparent-inputs")]
|
||||
use {
|
||||
crate::TransparentAddressMetadata,
|
||||
::transparent::{address::TransparentAddress, bundle::OutPoint},
|
||||
::transparent::{address::TransparentAddress, bundle::OutPoint, keys::NonHardenedChildIndex},
|
||||
core::ops::Range,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue