forked from zcash/librustzcash
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify change strategies, and deprecate or remove fee rules that no longer produce minable transactions #40
Closed
daira
wants to merge
9
commits into
nuttycom:wallet/multi_output_change_strategy
from
daira:wallet/multi_output_change_strategy
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c80893b
zcash_client_backend: Use an explicit struct for change output counts…
nuttycom f8970b0
zcash_client_backend: Add `WalletMeta` type & retrieval method.
nuttycom ff00f1a
zcash_client_backend: Make it possible for change strategies to use w…
nuttycom 56f5c94
zcash_client_backend: Clean up arguments to `single_change_output_bal…
nuttycom ebca2ec
zcash_client_backend: Add `fees::zip317::MultiOutputChangeStrategy`.
nuttycom 5afea2e
Apply suggestions from code review
nuttycom f58988a
Remove `fixed::FeeRule::standard` (which was misleadingly named because
daira 4ecd830
Remove `zcash_primitives::transaction::fees::StandardFeeRule::{PreZip…
daira e5ea08f
Refactor change strategies so that we can use a `CommonChangeStrategy`
daira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -794,6 +794,64 @@ impl<NoteRef> SpendableNotes<NoteRef> { | |
} | ||
} | ||
|
||
/// Metadata about the structure of the wallet for a particular account. | ||
/// | ||
/// At present this just contains counts of unspent outputs in each pool, but it may be extended in | ||
/// the future to contain note values or other more detailed information about wallet structure. | ||
/// | ||
/// Values of this type are intended to be used in selection of change output values. A value of | ||
/// this type may represent filtered data, and may therefore not count all of the unspent notes in | ||
/// the wallet. | ||
pub struct WalletMeta { | ||
sapling_note_count: usize, | ||
#[cfg(feature = "orchard")] | ||
orchard_note_count: usize, | ||
} | ||
|
||
impl WalletMeta { | ||
/// Constructs a new [`WalletMeta`] value from its constituent parts. | ||
pub fn new( | ||
sapling_note_count: usize, | ||
#[cfg(feature = "orchard")] orchard_note_count: usize, | ||
) -> Self { | ||
Self { | ||
sapling_note_count, | ||
#[cfg(feature = "orchard")] | ||
orchard_note_count, | ||
} | ||
} | ||
|
||
/// Returns the number of unspent notes in the wallet for the given shielded protocol. | ||
pub fn note_count(&self, protocol: ShieldedProtocol) -> usize { | ||
match protocol { | ||
ShieldedProtocol::Sapling => self.sapling_note_count, | ||
#[cfg(feature = "orchard")] | ||
ShieldedProtocol::Orchard => self.orchard_note_count, | ||
#[cfg(not(feature = "orchard"))] | ||
ShieldedProtocol::Orchard => 0, | ||
} | ||
} | ||
|
||
/// Returns the number of unspent Sapling notes belonging to the account for which this was | ||
/// generated. | ||
pub fn sapling_note_count(&self) -> usize { | ||
self.sapling_note_count | ||
} | ||
|
||
/// Returns the number of unspent Orchard notes belonging to the account for which this was | ||
/// generated. | ||
#[cfg(feature = "orchard")] | ||
pub fn orchard_note_count(&self) -> usize { | ||
self.orchard_note_count | ||
} | ||
|
||
/// Returns the total number of unspent shielded notes belonging to the account for which this | ||
/// was generated. | ||
pub fn total_note_count(&self) -> usize { | ||
self.sapling_note_count + self.note_count(ShieldedProtocol::Orchard) | ||
} | ||
} | ||
|
||
/// A trait representing the capability to query a data store for unspent transaction outputs | ||
/// belonging to a wallet. | ||
#[cfg_attr(feature = "test-dependencies", delegatable_trait)] | ||
|
@@ -838,6 +896,19 @@ pub trait InputSource { | |
exclude: &[Self::NoteRef], | ||
) -> Result<SpendableNotes<Self::NoteRef>, Self::Error>; | ||
|
||
/// Returns metadata describing the structure of the wallet for the specified account. | ||
/// | ||
/// The returned metadata value must exclude: | ||
/// - spent notes; | ||
/// - unspent notes having value less than the specified minimum value; | ||
/// - unspent notes identified in the given `exclude` list. | ||
fn get_wallet_metadata( | ||
&self, | ||
account: Self::AccountId, | ||
min_value: NonNegativeAmount, | ||
exclude: &[Self::NoteRef], | ||
) -> Result<Option<WalletMeta>, Self::Error>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this change semantically - I guess |
||
|
||
/// Fetches the transparent output corresponding to the provided `outpoint`. | ||
/// | ||
/// Returns `Ok(None)` if the UTXO is not known to belong to the wallet or is not | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of
CommonChangeStrategy
, we should probably call thisSinglePoolChangeStrategy
as the distinguishing feature is now that it sends change to a single pool.