Skip to main content

InputSignatureRef

Struct InputSignatureRef 

Source
pub struct InputSignatureRef<'a>(/* private fields */);
Expand description

A borrowed equivalent of the InputSignature data type. It can be useful for checking incoming signatures from unauthorized sources.

§Examples

use secp256k1::Secp256k1;
use btc_transaction_utils::InputSignatureRef;

// Get a signature from the unknown source.
let bytes = hex::decode(
    "304402201538279618a4626653775069b43d4315c7d2ff3000\
     8d339d0ed31ff41e628e71022028f3182fc39df28201ca4d7d\
     489aece7bc5bc6bfe05b09b6a9d3b70bf5f3743101",
).unwrap();
// Try to decode it.
let signature = InputSignatureRef::from_bytes(&bytes)
    .expect("Signature should be correct");

Implementations§

Source§

impl<'a> InputSignatureRef<'a>

Source

pub fn from_bytes(bytes: &'a [u8]) -> Result<InputSignatureRef<'a>, Error>

Tries to construct input signature from the raw bytes.

Source

pub fn content(&self) -> &[u8]

Returns the signature content in canonical form.

Source

pub fn sighash_type(&self) -> SigHashType

Returns a sighash type of the given input signature.

Trait Implementations§

Source§

impl<'a> AsRef<[u8]> for InputSignatureRef<'a>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Clone for InputSignatureRef<'a>

Source§

fn clone(&self) -> InputSignatureRef<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for InputSignatureRef<'a>

Source§

impl<'a> Debug for InputSignatureRef<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a InputSignature> for InputSignatureRef<'a>

Source§

fn from(s: &'a InputSignature) -> InputSignatureRef<'_>

Converts to this type from the input type.
Source§

impl<'a> From<InputSignatureRef<'a>> for Vec<u8>

Source§

fn from(s: InputSignatureRef<'a>) -> Vec<u8>

Converts to this type from the input type.
Source§

impl<'a> From<InputSignatureRef<'a>> for InputSignature

Source§

fn from(s: InputSignatureRef<'a>) -> InputSignature

Converts to this type from the input type.
Source§

impl<'a> PartialEq for InputSignatureRef<'a>

Source§

fn eq(&self, other: &InputSignatureRef<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for InputSignatureRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for InputSignatureRef<'a>

§

impl<'a> RefUnwindSafe for InputSignatureRef<'a>

§

impl<'a> Send for InputSignatureRef<'a>

§

impl<'a> Sync for InputSignatureRef<'a>

§

impl<'a> Unpin for InputSignatureRef<'a>

§

impl<'a> UnsafeUnpin for InputSignatureRef<'a>

§

impl<'a> UnwindSafe for InputSignatureRef<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Base32Len for T
where T: AsRef<[u8]>,

Source§

fn base32_len(&self) -> usize

Calculate the base32 serialized length
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<'f, T> CheckBase32<Vec<u5>> for T
where T: AsRef<[u8]>,

Source§

type Err = Error

Error type if conversion fails
Source§

fn check_base32(self) -> Result<Vec<u5>, <T as CheckBase32<Vec<u5>>>::Err>

Check if all values are in range and return array-like struct of u5 values
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToBase32 for T
where T: AsRef<[u8]>,

Source§

fn write_base32<W>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err>
where W: WriteBase32,

Encode as base32 and write it to the supplied writer Implementations shouldn’t allocate.
Source§

fn to_base32(&self) -> Vec<u5>

Convert Self to base32 vector
Source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

Source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
Source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.