pub enum EncodeSigningDataResult<E> {
SighashSingleBug,
WriteResult(Result<(), E>),
}
Expand description
Result of Transaction::encode_signing_data_to
.
This type forces the caller to handle SIGHASH_SINGLE bug case.
This corner case can’t be expressed using standard Result
,
in a way that is both convenient and not-prone to accidental
mistakes (like calling .expect("writer never fails")
).
Variants§
SighashSingleBug
Input data is an instance of SIGHASH_SINGLE
bug
WriteResult(Result<(), E>)
Operation performed normally.
Implementations§
§impl<E> EncodeSigningDataResult<E>
impl<E> EncodeSigningDataResult<E>
pub fn is_sighash_single_bug(self) -> Result<bool, E>
pub fn is_sighash_single_bug(self) -> Result<bool, E>
Checks for SIGHASH_SINGLE bug returning error if the writer failed.
This method is provided for easy and correct handling of the result because SIGHASH_SINGLE bug is a special case that must not be ignored nor cause panicking. Since the data is usually written directly into a hasher which never fails, the recommended pattern to handle this is:
if tx.encode_signing_data_to(&mut writer, input_index, &script_pubkey, sighash_u32)
.is_sighash_single_bug()
.expect("writer can't fail") {
// use a hash value of "1", instead of computing the actual hash due to SIGHASH_SINGLE bug
}
pub fn map_err<E2, F>(self, f: F) -> EncodeSigningDataResult<E2>where
F: FnOnce(E) -> E2,
pub fn map_err<E2, F>(self, f: F) -> EncodeSigningDataResult<E2>where
F: FnOnce(E) -> E2,
Maps a Result<T, E>
to Result<T, F>
by applying a function to a
contained Err
value, leaving an Ok
value untouched.
Like Result::map_err
.
Auto Trait Implementations§
impl<E> Freeze for EncodeSigningDataResult<E>where
E: Freeze,
impl<E> RefUnwindSafe for EncodeSigningDataResult<E>where
E: RefUnwindSafe,
impl<E> Send for EncodeSigningDataResult<E>where
E: Send,
impl<E> Sync for EncodeSigningDataResult<E>where
E: Sync,
impl<E> Unpin for EncodeSigningDataResult<E>where
E: Unpin,
impl<E> UnwindSafe for EncodeSigningDataResult<E>where
E: UnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§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
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any
.§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request