zcash_client_backend: rename `WalletNote` to `Note`
This commit is contained in:
parent
28319ffc38
commit
1b036f1e0d
|
@ -29,7 +29,7 @@ and this library adheres to Rust's notion of
|
||||||
functionality and move it behind the `transparent-inputs` feature flag.
|
functionality and move it behind the `transparent-inputs` feature flag.
|
||||||
- `zcash_client_backend::fees::{standard, sapling}`
|
- `zcash_client_backend::fees::{standard, sapling}`
|
||||||
- `zcash_client_backend::wallet`:
|
- `zcash_client_backend::wallet`:
|
||||||
- `WalletNote`
|
- `Note`
|
||||||
- `ReceivedNote`
|
- `ReceivedNote`
|
||||||
- `WalletSaplingOutput::recipient_key_scope`
|
- `WalletSaplingOutput::recipient_key_scope`
|
||||||
- `zcash_client_backend::zip321::TransactionRequest::total`
|
- `zcash_client_backend::zip321::TransactionRequest::total`
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
||||||
decrypt_transaction,
|
decrypt_transaction,
|
||||||
fees::{self, ChangeValue, DustOutputPolicy},
|
fees::{self, ChangeValue, DustOutputPolicy},
|
||||||
keys::UnifiedSpendingKey,
|
keys::UnifiedSpendingKey,
|
||||||
wallet::{OvkPolicy, Recipient, WalletNote},
|
wallet::{Note, OvkPolicy, Recipient},
|
||||||
zip321::{self, Payment},
|
zip321::{self, Payment},
|
||||||
PoolType, ShieldedProtocol,
|
PoolType, ShieldedProtocol,
|
||||||
};
|
};
|
||||||
|
@ -586,7 +586,7 @@ where
|
||||||
.iter()
|
.iter()
|
||||||
.map(|selected| {
|
.map(|selected| {
|
||||||
match selected.note() {
|
match selected.note() {
|
||||||
WalletNote::Sapling(note) => {
|
Note::Sapling(note) => {
|
||||||
let key = match selected.spending_key_scope() {
|
let key = match selected.spending_key_scope() {
|
||||||
Scope::External => usk.sapling().clone(),
|
Scope::External => usk.sapling().clone(),
|
||||||
Scope::Internal => usk.sapling().derive_internal(),
|
Scope::Internal => usk.sapling().derive_internal(),
|
||||||
|
@ -600,7 +600,7 @@ where
|
||||||
Ok((key, note, merkle_path))
|
Ok((key, note, merkle_path))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
WalletNote::Orchard(_) => {
|
Note::Orchard(_) => {
|
||||||
// FIXME: Implement this once `Proposal` has been refactored to
|
// FIXME: Implement this once `Proposal` has been refactored to
|
||||||
// include Orchard notes.
|
// include Orchard notes.
|
||||||
panic!("Orchard spends are not yet supported");
|
panic!("Orchard spends are not yet supported");
|
||||||
|
|
|
@ -237,20 +237,20 @@ impl<N, S> WalletSaplingOutput<N, S> {
|
||||||
|
|
||||||
/// An enumeration of supported shielded note types for use in [`ReceivedNote`]
|
/// An enumeration of supported shielded note types for use in [`ReceivedNote`]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum WalletNote {
|
pub enum Note {
|
||||||
Sapling(sapling::Note),
|
Sapling(sapling::Note),
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
Orchard(orchard::Note),
|
Orchard(orchard::Note),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WalletNote {
|
impl Note {
|
||||||
pub fn value(&self) -> NonNegativeAmount {
|
pub fn value(&self) -> NonNegativeAmount {
|
||||||
match self {
|
match self {
|
||||||
WalletNote::Sapling(n) => n.value().try_into().expect(
|
Note::Sapling(n) => n.value().try_into().expect(
|
||||||
"Sapling notes must have values in the range of valid non-negative ZEC values.",
|
"Sapling notes must have values in the range of valid non-negative ZEC values.",
|
||||||
),
|
),
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
WalletNote::Orchard(n) => NonNegativeAmount::from_u64(n.value().inner()).expect(
|
Note::Orchard(n) => NonNegativeAmount::from_u64(n.value().inner()).expect(
|
||||||
"Orchard notes must have values in the range of valid non-negative ZEC values.",
|
"Orchard notes must have values in the range of valid non-negative ZEC values.",
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ pub struct ReceivedNote<NoteRef> {
|
||||||
note_id: NoteRef,
|
note_id: NoteRef,
|
||||||
txid: TxId,
|
txid: TxId,
|
||||||
output_index: u16,
|
output_index: u16,
|
||||||
note: WalletNote,
|
note: Note,
|
||||||
spending_key_scope: Scope,
|
spending_key_scope: Scope,
|
||||||
note_commitment_tree_position: Position,
|
note_commitment_tree_position: Position,
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ impl<NoteRef> ReceivedNote<NoteRef> {
|
||||||
note_id: NoteRef,
|
note_id: NoteRef,
|
||||||
txid: TxId,
|
txid: TxId,
|
||||||
output_index: u16,
|
output_index: u16,
|
||||||
note: WalletNote,
|
note: Note,
|
||||||
spending_key_scope: Scope,
|
spending_key_scope: Scope,
|
||||||
note_commitment_tree_position: Position,
|
note_commitment_tree_position: Position,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -297,7 +297,7 @@ impl<NoteRef> ReceivedNote<NoteRef> {
|
||||||
pub fn output_index(&self) -> u16 {
|
pub fn output_index(&self) -> u16 {
|
||||||
self.output_index
|
self.output_index
|
||||||
}
|
}
|
||||||
pub fn note(&self) -> &WalletNote {
|
pub fn note(&self) -> &Note {
|
||||||
&self.note
|
&self.note
|
||||||
}
|
}
|
||||||
pub fn value(&self) -> NonNegativeAmount {
|
pub fn value(&self) -> NonNegativeAmount {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use incrementalmerkletree::Position;
|
||||||
use rusqlite::{named_params, params, types::Value, Connection, Row};
|
use rusqlite::{named_params, params, types::Value, Connection, Row};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use sapling::{Diversifier, Note, Nullifier, Rseed};
|
use sapling::{self, Diversifier, Nullifier, Rseed};
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
consensus::{self, BlockHeight},
|
consensus::{self, BlockHeight},
|
||||||
memo::MemoBytes,
|
memo::MemoBytes,
|
||||||
|
@ -18,7 +18,7 @@ use zcash_primitives::{
|
||||||
|
|
||||||
use zcash_client_backend::{
|
use zcash_client_backend::{
|
||||||
keys::UnifiedFullViewingKey,
|
keys::UnifiedFullViewingKey,
|
||||||
wallet::{ReceivedNote, WalletNote, WalletSaplingOutput},
|
wallet::{Note, ReceivedNote, WalletSaplingOutput},
|
||||||
DecryptedOutput, TransferType,
|
DecryptedOutput, TransferType,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ use super::{memo_repr, parse_scope, scope_code, wallet_birthday};
|
||||||
pub(crate) trait ReceivedSaplingOutput {
|
pub(crate) trait ReceivedSaplingOutput {
|
||||||
fn index(&self) -> usize;
|
fn index(&self) -> usize;
|
||||||
fn account(&self) -> AccountId;
|
fn account(&self) -> AccountId;
|
||||||
fn note(&self) -> &Note;
|
fn note(&self) -> &sapling::Note;
|
||||||
fn memo(&self) -> Option<&MemoBytes>;
|
fn memo(&self) -> Option<&MemoBytes>;
|
||||||
fn is_change(&self) -> bool;
|
fn is_change(&self) -> bool;
|
||||||
fn nullifier(&self) -> Option<&sapling::Nullifier>;
|
fn nullifier(&self) -> Option<&sapling::Nullifier>;
|
||||||
|
@ -45,7 +45,7 @@ impl ReceivedSaplingOutput for WalletSaplingOutput<sapling::Nullifier, Scope> {
|
||||||
fn account(&self) -> AccountId {
|
fn account(&self) -> AccountId {
|
||||||
WalletSaplingOutput::account(self)
|
WalletSaplingOutput::account(self)
|
||||||
}
|
}
|
||||||
fn note(&self) -> &Note {
|
fn note(&self) -> &sapling::Note {
|
||||||
WalletSaplingOutput::note(self)
|
WalletSaplingOutput::note(self)
|
||||||
}
|
}
|
||||||
fn memo(&self) -> Option<&MemoBytes> {
|
fn memo(&self) -> Option<&MemoBytes> {
|
||||||
|
@ -66,14 +66,14 @@ impl ReceivedSaplingOutput for WalletSaplingOutput<sapling::Nullifier, Scope> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReceivedSaplingOutput for DecryptedOutput<Note> {
|
impl ReceivedSaplingOutput for DecryptedOutput<sapling::Note> {
|
||||||
fn index(&self) -> usize {
|
fn index(&self) -> usize {
|
||||||
self.index
|
self.index
|
||||||
}
|
}
|
||||||
fn account(&self) -> AccountId {
|
fn account(&self) -> AccountId {
|
||||||
self.account
|
self.account
|
||||||
}
|
}
|
||||||
fn note(&self) -> &Note {
|
fn note(&self) -> &sapling::Note {
|
||||||
&self.note
|
&self.note
|
||||||
}
|
}
|
||||||
fn memo(&self) -> Option<&MemoBytes> {
|
fn memo(&self) -> Option<&MemoBytes> {
|
||||||
|
@ -163,7 +163,7 @@ fn to_spendable_note<P: consensus::Parameters>(
|
||||||
note_id,
|
note_id,
|
||||||
txid,
|
txid,
|
||||||
output_index,
|
output_index,
|
||||||
WalletNote::Sapling(sapling::Note::from_parts(
|
Note::Sapling(sapling::Note::from_parts(
|
||||||
recipient,
|
recipient,
|
||||||
note_value.into(),
|
note_value.into(),
|
||||||
rseed,
|
rseed,
|
||||||
|
@ -471,10 +471,11 @@ pub(crate) mod tests {
|
||||||
use zcash_proofs::prover::LocalTxProver;
|
use zcash_proofs::prover::LocalTxProver;
|
||||||
|
|
||||||
use sapling::{
|
use sapling::{
|
||||||
|
self,
|
||||||
note_encryption::try_sapling_output_recovery,
|
note_encryption::try_sapling_output_recovery,
|
||||||
prover::{OutputProver, SpendProver},
|
prover::{OutputProver, SpendProver},
|
||||||
zip32::ExtendedSpendingKey,
|
zip32::ExtendedSpendingKey,
|
||||||
Node, Note, PaymentAddress,
|
Node, PaymentAddress,
|
||||||
};
|
};
|
||||||
use zcash_primitives::{
|
use zcash_primitives::{
|
||||||
block::BlockHash,
|
block::BlockHash,
|
||||||
|
@ -1045,7 +1046,7 @@ pub(crate) mod tests {
|
||||||
let send_and_recover_with_policy = |st: &mut TestState<BlockCache>,
|
let send_and_recover_with_policy = |st: &mut TestState<BlockCache>,
|
||||||
ovk_policy|
|
ovk_policy|
|
||||||
-> Result<
|
-> Result<
|
||||||
Option<(Note, PaymentAddress, MemoBytes)>,
|
Option<(sapling::Note, PaymentAddress, MemoBytes)>,
|
||||||
Error<
|
Error<
|
||||||
SqliteClientError,
|
SqliteClientError,
|
||||||
commitment_tree::Error,
|
commitment_tree::Error,
|
||||||
|
|
Loading…
Reference in New Issue