pub struct Witness { /* private fields */ }
Expand description
The Witness is the data used to unlock bitcoins since the segwit upgrade
Can be logically seen as an array of byte-arrays Vec<Vec<u8>>
and indeed you can convert from
it Witness::from_vec
and convert into it Witness::to_vec
.
For serialization and deserialization performance it is stored internally as a single Vec
,
saving some allocations.
Implementations
sourceimpl Witness
impl Witness
sourcepub fn to_vec(&self) -> Vec<Vec<u8>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn to_vec(&self) -> Vec<Vec<u8>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Convenience method to create an array of byte-arrays from this witness
sourcepub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = &'a [u8];
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = &'a [u8];
Returns a struct implementing Iterator
sourcepub fn serialized_len(&self) -> usize
pub fn serialized_len(&self) -> usize
Returns the bytes required when this Witness is consensus encoded
sourcepub fn push<T: AsRef<[u8]>>(&mut self, new_element: T)
pub fn push<T: AsRef<[u8]>>(&mut self, new_element: T)
Push a new element on the witness, requires an allocation
sourcepub fn second_to_last(&self) -> Option<&[u8]>
pub fn second_to_last(&self) -> Option<&[u8]>
Return the second-to-last element in the witness, if any
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Witness
impl<'de> Deserialize<'de> for Witness
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Deserialize for Witness
impl Deserialize for Witness
sourcefn deserialize(bytes: &[u8]) -> Result<Self, Error>
fn deserialize(bytes: &[u8]) -> Result<Self, Error>
Deserialize a value from raw data.
sourceimpl Ord for Witness
impl Ord for Witness
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Witness> for Witness
impl PartialOrd<Witness> for Witness
sourcefn partial_cmp(&self, other: &Witness) -> Option<Ordering>
fn partial_cmp(&self, other: &Witness) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Witness
impl StructuralEq for Witness
impl StructuralPartialEq for Witness
Auto Trait Implementations
impl RefUnwindSafe for Witness
impl Send for Witness
impl Sync for Witness
impl Unpin for Witness
impl UnwindSafe for Witness
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more