pub struct ConfirmationsPolicy { /* private fields */ }Expand description
Implementations§
Source§impl ConfirmationsPolicy
impl ConfirmationsPolicy
Sourcepub const MIN: Self
pub const MIN: Self
A policy to use the minimum number of confirmations possible: 1 confirmation for shielded notes irrespective of origin, and 0 confirmations for spends of transparent UTXOs in wallet-internal shielding transactions.
Sourcepub fn new(
trusted: NonZeroU32,
untrusted: NonZeroU32,
allow_zero_conf_shielding: bool,
) -> Result<Self, ConfirmationsPolicyError>
pub fn new( trusted: NonZeroU32, untrusted: NonZeroU32, allow_zero_conf_shielding: bool, ) -> Result<Self, ConfirmationsPolicyError>
Constructs a new ConfirmationsPolicy with trusted and untrusted fields set to the
provided values.
The number of confirmations required for trusted notes must be less than or equal to the number of confirmations required for untrusted notes; this returns an error if this invariant is violated.
WARNING: This should only be used with great care to avoid problems of transaction
distinguishability; prefer ConfirmationsPolicy::default() instead.
Sourcepub fn new_symmetrical(
min_confirmations: NonZeroU32,
allow_zero_conf_shielding: bool,
) -> Self
pub fn new_symmetrical( min_confirmations: NonZeroU32, allow_zero_conf_shielding: bool, ) -> Self
Constructs a new ConfirmationsPolicy with trusted and untrusted fields both
set to min_confirmations.
WARNING: This should only be used with great care to avoid problems of transaction
distinguishability; prefer ConfirmationsPolicy::default() instead.
Sourcepub fn new_unchecked(
trusted: u32,
untrusted: u32,
allow_zero_conf_shielding: bool,
) -> Self
Available on crate features test-dependencies only.
pub fn new_unchecked( trusted: u32, untrusted: u32, allow_zero_conf_shielding: bool, ) -> Self
test-dependencies only.Constructs a new ConfirmationsPolicy with trusted and untrusted fields set to the
provided values, which must both be nonzero. The number of trusted confirmations required
must be less than or equal to the number of untrusted confirmations required.
§Panics
Panics if trusted > untrusted or either argument value is zero.
Sourcepub fn new_symmetrical_unchecked(
min_confirmations: u32,
allow_zero_conf_shielding: bool,
) -> Self
Available on crate features test-dependencies only.
pub fn new_symmetrical_unchecked( min_confirmations: u32, allow_zero_conf_shielding: bool, ) -> Self
test-dependencies only.Constructs a new ConfirmationsPolicy with trusted and untrusted fields both
set to min_confirmations.
§Panics
Panics if min_confirmations == 0
Sourcepub fn trusted(&self) -> NonZeroU32
pub fn trusted(&self) -> NonZeroU32
Returns the number of confirmations required before trusted notes may be spent.
See ZIP 315 for details.
Sourcepub fn untrusted(&self) -> NonZeroU32
pub fn untrusted(&self) -> NonZeroU32
Returns the number of confirmations required before untrusted notes may be spent.
See ZIP 315 for details.
Sourcepub fn anchor_height(&self, target_height: TargetHeight) -> BlockHeight
pub fn anchor_height(&self, target_height: TargetHeight) -> BlockHeight
Returns the shielded anchor height to use for a transaction targeting target_height under
this policy: target_height less the number of required trusted confirmations.
This is the anchor used to interpret a proposal step that carries no explicit anchor height —
a purely transparent step, whose anchor is unused (see
crate::proposal::Step::anchor_height).
Sourcepub fn bucketed(
&self,
grid: AnchorGrid,
target_height: TargetHeight,
activation_height: BlockHeight,
) -> Option<Self>
pub fn bucketed( &self, grid: AnchorGrid, target_height: TargetHeight, activation_height: BlockHeight, ) -> Option<Self>
Returns this policy adjusted so that the shielded anchor for target_height lands on a
boundary of grid, or None if no boundary is reachable.
A ZIP 318 pool crossing is proved against a boundary block rather than the chain tip, so that many wallets’ crossings share a small set of anchors instead of each pinning a unique recent block.
Bucketing is expressed as a RAISED CONFIRMATION REQUIREMENT rather than as a separately
lowered anchor, because the anchor and the bound on which notes may be spent are the same
quantity: target_height less the required confirmations. Moving that one number moves
both together, which is what makes it impossible to select a note having no witness at the
bucketed anchor. Lowering the anchor on its own would leave two numbers free to drift.
The untrusted requirement is raised to match when it would otherwise fall below the trusted
one, preserving this type’s trusted <= untrusted invariant.
The boundary chosen is the one BEFORE the most recent one — an anchor age of 1, the smallest ZIP 318 admits. Anchoring to the most recent boundary would be an age of 0, which no migration transfer uses.
activation_height is the activation of the pool being crossed into; the chosen boundary
must lie strictly above it.
Returns None when no usable boundary is reachable: when the ordinary anchor lies below the
first boundary after activation_height, or where the required confirmations would reach
back past the genesis block. Reporting that as “unable to bucket” is what lets a caller fall
back, rather than build a proposal that is bound to fail.
Sourcepub fn allow_zero_conf_shielding(&self) -> bool
Available on crate feature transparent-inputs only.
pub fn allow_zero_conf_shielding(&self) -> bool
transparent-inputs only.Returns whether or not transparent inputs may be spent with zero confirmations in shielding transactions.
Sourcepub fn confirmations_until_spendable(
&self,
target_height: TargetHeight,
pool_type: PoolType,
receiving_key_scope: Option<Scope>,
mined_height: Option<BlockHeight>,
tx_trusted: bool,
max_shielding_input_height: Option<BlockHeight>,
tx_shielding_inputs_trusted: bool,
) -> u32
pub fn confirmations_until_spendable( &self, target_height: TargetHeight, pool_type: PoolType, receiving_key_scope: Option<Scope>, mined_height: Option<BlockHeight>, tx_trusted: bool, max_shielding_input_height: Option<BlockHeight>, tx_shielding_inputs_trusted: bool, ) -> u32
Returns the number of confirmations until a transaction output is considered spendable, given information about the output and the inputs to the transaction that produced it.
§Parameters
target_height: The minimum height at which the output will be potentially spent.pool_type: The Zcash pool that the output was received into.receiving_key_scope: The ZIP 32 [Scope] of the key that received the output, orNoneif the scope is unknown or corresponds to the ephemeral transparent key scope.mined_height: The block height at which the transaction that produced the output was mined, if any.tx_trusted: A boolean flag indicating whether the received transaction has been explicitly marked as trusted by the user.max_shielding_input_height: For outputs that are the result of wallet-internal shielding transactions, the maximum height at which any transparent input to that transaction was received.tx_shielding_inputs_trusted: For outputs that are the result of wallet-internal shielding transactions, a flag indicating whether all transparent inputs to that transaction have been explicitly marked as trusted by the user.
Trait Implementations§
Source§impl Clone for ConfirmationsPolicy
impl Clone for ConfirmationsPolicy
impl Copy for ConfirmationsPolicy
Source§impl Debug for ConfirmationsPolicy
impl Debug for ConfirmationsPolicy
Source§impl Default for ConfirmationsPolicy
The default confirmations policy according to ZIP 315.
impl Default for ConfirmationsPolicy
The default confirmations policy according to ZIP 315.
- Require 3 confirmations for “trusted” transaction outputs (outputs produced by the wallet)
- Require 10 confirmations for “untrusted” outputs (those sent to the wallet by external/third parties)
- Allow zero-conf shielding of transparent UTXOs irrespective of their origin, but treat the resulting shielding transaction’s outputs as though the original transparent UTXOs had instead been received as untrusted shielded outputs.
impl Eq for ConfirmationsPolicy
Source§impl PartialEq for ConfirmationsPolicy
impl PartialEq for ConfirmationsPolicy
impl StructuralPartialEq for ConfirmationsPolicy
Auto Trait Implementations§
impl Freeze for ConfirmationsPolicy
impl RefUnwindSafe for ConfirmationsPolicy
impl Send for ConfirmationsPolicy
impl Sync for ConfirmationsPolicy
impl Unpin for ConfirmationsPolicy
impl UnsafeUnpin for ConfirmationsPolicy
impl UnwindSafe for ConfirmationsPolicy
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PossiblyOption<T> for T
impl<T> PossiblyOption<T> for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.