Skip to content

Commit

Permalink
add implementations of InputSource for MemoryWalletDB and Conditional…
Browse files Browse the repository at this point in the history
…lySelectable for AccountId
  • Loading branch information
willemolding committed Aug 27, 2024
1 parent ce936d3 commit 144bfca
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions zcash_client_memory/src/mem_wallet/input_source.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use zcash_client_backend::data_api::InputSource;

use crate::mem_wallet::{AccountId, MemoryWalletDb};

impl InputSource for MemoryWalletDb {
type Error = crate::error::Error;
type AccountId = crate::mem_wallet::AccountId;
type NoteRef = crate::mem_wallet::NoteId;

fn get_spendable_note(
&self,
txid: &zcash_primitives::transaction::TxId,
protocol: zcash_protocol::ShieldedProtocol,
index: u32,
) -> Result<
Option<
zcash_client_backend::wallet::ReceivedNote<
Self::NoteRef,
zcash_client_backend::wallet::Note,
>,
>,
Self::Error,
> {
todo!()
}

fn select_spendable_notes(
&self,
account: Self::AccountId,
target_value: zcash_protocol::value::Zatoshis,
sources: &[zcash_protocol::ShieldedProtocol],
anchor_height: zcash_protocol::consensus::BlockHeight,
exclude: &[Self::NoteRef],
) -> Result<zcash_client_backend::data_api::SpendableNotes<Self::NoteRef>, Self::Error> {
todo!()
}
}
10 changes: 10 additions & 0 deletions zcash_client_memory/src/mem_wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
num::NonZeroU32,
ops::Deref,
};
use subtle::ConditionallySelectable;
use zcash_keys::keys::{AddressGenerationError, DerivationError, UnifiedIncomingViewingKey};
use zip32::{fingerprint::SeedFingerprint, DiversifierIndex, Scope};

Expand Down Expand Up @@ -55,6 +56,7 @@ use zcash_client_backend::{data_api::ORCHARD_SHARD_HEIGHT, wallet::WalletOrchard

use crate::error::Error;

mod input_source;
mod tables;
mod wallet_commitment_trees;
mod wallet_read;
Expand Down Expand Up @@ -280,6 +282,14 @@ impl Deref for AccountId {
}
}

impl ConditionallySelectable for AccountId {
fn conditional_select(a: &Self, b: &Self, choice: subtle::Choice) -> Self {
AccountId(ConditionallySelectable::conditional_select(
&a.0, &b.0, choice,
))
}
}

/// An account stored in a `zcash_client_sqlite` database.
#[derive(Debug, Clone)]
pub struct Account {
Expand Down

0 comments on commit 144bfca

Please sign in to comment.