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§

source§

impl<E> EncodeSigningDataResult<E>

source

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:

let cache = SighashCache::new(&tx);
if cache.legacy_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
}
source

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§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V