use bip0039::Mnemonic;
use secrecy::ExposeSecret;
use zcash_keys::keys::{Era, UnifiedSpendingKey};
use crate::wallet::keys::unified::UnifiedKeyStore;
use super::LightWallet;
pub mod examples;
#[cfg(test)]
pub mod tests;
pub async fn assert_wallet_capability_matches_seed(
wallet: &LightWallet,
expected_seed_phrase: String,
) {
let actual_seed_phrase = wallet.mnemonic_phrase().unwrap();
assert_eq!(expected_seed_phrase, actual_seed_phrase);
let expected_mnemonic =
Mnemonic::<bip0039::English>::from_phrase(expected_seed_phrase).unwrap();
let expected_keys = crate::wallet::keys::unified::UnifiedKeyStore::new_from_mnemonic(
wallet.chain_type,
&expected_mnemonic,
zip32::AccountId::ZERO,
)
.unwrap();
let UnifiedKeyStore::Spend(usk) = &wallet
.unified_key_store
.get(&zip32::AccountId::ZERO)
.unwrap()
else {
panic!("Expected Unified Spending Key");
};
assert_eq!(
usk.to_bytes(Era::Orchard).expose_secret(),
UnifiedSpendingKey::try_from(&expected_keys)
.unwrap()
.to_bytes(Era::Orchard)
.expose_secret()
);
}
pub async fn assert_wallet_capability_contains_n_triple_pool_receivers(
wallet: &LightWallet,
expected_num_addresses: usize,
) {
assert_eq!(wallet.unified_addresses.len(), expected_num_addresses);
for addr in wallet.unified_addresses.values() {
assert!(addr.orchard().is_some());
assert!(addr.sapling().is_some());
assert!(addr.transparent().is_some());
}
}