use bip0039::Mnemonic;
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.get_seed_phrase().await.unwrap();
assert_eq!(expected_seed_phrase, actual_seed_phrase);
let expected_mnemonic = (
Mnemonic::<bip0039::English>::from_phrase(expected_seed_phrase).unwrap(),
0,
);
let expected_keys = crate::wallet::keys::unified::UnifiedKeyStore::new_from_mnemonic(
&wallet.network,
&expected_mnemonic.0,
expected_mnemonic.1,
)
.unwrap();
let UnifiedKeyStore::Spend(usk) = &wallet.unified_key_store else {
panic!("Expected Unified Spending Key");
};
assert_eq!(
usk.to_bytes(Era::Orchard),
UnifiedSpendingKey::try_from(&expected_keys)
.unwrap()
.to_bytes(Era::Orchard)
);
}
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());
}
}