pub struct ScriptNum;Expand description
Bitcoin Script number utilities.
Provides conversion between stack byte arrays and BigNumber values, following Bitcoin’s sign-magnitude little-endian encoding.
Implementations§
Source§impl ScriptNum
impl ScriptNum
Sourcepub fn is_minimally_encoded(bytes: &[u8]) -> bool
pub fn is_minimally_encoded(bytes: &[u8]) -> bool
Checks if bytes are minimally encoded as a script number.
A number is minimally encoded if:
- It’s empty (zero), or
- The last byte is non-zero after removing the sign bit, or
- The second-to-last byte has its high bit set (justifying the extra byte)
Sourcepub fn cast_to_bool(bytes: &[u8]) -> bool
pub fn cast_to_bool(bytes: &[u8]) -> bool
Casts a byte array to a boolean value.
Returns false for:
- Empty array
- Array of all zeros
- Negative zero
[0x80]or[0x00, ..., 0x80]
Returns true otherwise.
Auto Trait Implementations§
impl Freeze for ScriptNum
impl RefUnwindSafe for ScriptNum
impl Send for ScriptNum
impl Sync for ScriptNum
impl Unpin for ScriptNum
impl UnsafeUnpin for ScriptNum
impl UnwindSafe for ScriptNum
Blanket Implementations§
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
Mutably borrows from an owned value. Read more