Skip to content

Commit

Permalink
add fix for orchard support
Browse files Browse the repository at this point in the history
  • Loading branch information
willemolding committed Sep 9, 2024
1 parent 1f133fa commit ef331fe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
10 changes: 10 additions & 0 deletions zcash_client_memory/src/testing/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ mod sapling_tests {
}
}

#[cfg(test)]
#[cfg(feature = "orchard")]
mod orchard_tests {
use zcash_client_backend::data_api::testing::orchard::OrchardPoolTester;

#[test]
fn send_single_step_proposed_transfer() {
crate::testing::pool::send_single_step_proposed_transfer::<OrchardPoolTester>()
}
}
10 changes: 7 additions & 3 deletions zcash_client_memory/src/types/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,16 @@ impl SentNoteTable {
output: &SentTransactionOutput<AccountId>,
) {
let protocol = match output.recipient() {
Recipient::External(_, PoolType::Shielded(protocol)) => protocol,
_ => &ShieldedProtocol::Sapling, // Not exactly sure what what to do here since we cant get the pool type
Recipient::External(_, PoolType::Shielded(protocol)) => protocol.clone(),
Recipient::External(_, PoolType::Transparent)
| Recipient::EphemeralTransparent { .. } => {
unimplemented!("Transparent transfers not yet supported")
}
Recipient::InternalAccount { note, .. } => note.protocol(),
};
let note_id = NoteId::new(
tx.tx().txid(),
*protocol,
protocol,
output.output_index().try_into().unwrap(),
);
self.0.insert(
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_memory/src/wallet_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ impl<P: consensus::Parameters> WalletRead for MemoryWalletDb<P> {
///
/// Currently test-only, as production use could return a very large number of results; either
/// pagination or a streaming design will be necessary to stabilize this feature for production
/// use.
/// use.
#[cfg(any(test, feature = "test-dependencies"))]
fn get_tx_history(
&self,
Expand Down
14 changes: 10 additions & 4 deletions zcash_client_memory/src/wallet_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,18 @@ Instead derive the ufvk in the calling code and import it using `import_account_
}
}
// Mark orchard notes as spent
if let Some(_bundle) = sent_tx.tx().orchard_bundle() {
if let Some(bundle) = sent_tx.tx().orchard_bundle() {
#[cfg(feature = "orchard")]
{
for action in _bundle.actions() {
self.mark_orchard_note_spent(*action.nullifier(), sent_tx.tx().txid())?;
for action in bundle.actions() {
match self.mark_orchard_note_spent(*action.nullifier(), sent_tx.tx().txid()) {
Ok(()) => {}
Err(Error::NoteNotFound) => {
// This is expected as some of the actions will be new outputs we don't have notes for
// The ones we do recognize will be marked as spent
}
Err(e) => return Err(e),
}
}
}

Expand All @@ -676,7 +683,6 @@ Instead derive the ufvk in the calling code and import it using `import_account_
}

for output in sent_tx.outputs() {
// TODO: insert sent output
self.sent_notes.insert_sent_output(sent_tx, output);

match output.recipient() {
Expand Down

0 comments on commit ef331fe

Please sign in to comment.