Miniscript

Struct Miniscript 

Source
pub struct Miniscript { /* private fields */ }
Expand description

A parsed miniscript node.

This is a safe wrapper around the C++ miniscript implementation.

Implementations§

Source§

impl Miniscript

Source

pub fn from_str(input: &str, context: Context) -> Result<Self, Error>

Parse a miniscript from a string.

§Arguments
  • input - The miniscript string (e.g., “and_v(v:pk(A),pk(B))”)
  • context - The script context (WSH or Tapscript)
§Errors

Returns an error if parsing fails.

Source

pub fn to_string(&self) -> Option<String>

Convert the miniscript back to a string.

Source

pub fn is_valid(&self) -> bool

Check if the miniscript is valid (type-checks correctly).

Source

pub fn is_sane(&self) -> bool

Check if the miniscript is sane.

This includes checks for:

  • No duplicate keys
  • No timelock mixing
  • Within resource limits
Source

pub fn get_type(&self) -> Option<String>

Get the type properties of the miniscript.

Returns a string like “Bdems” where each letter indicates a property.

Source

pub fn max_satisfaction_size(&self) -> Option<usize>

Get the maximum witness size for satisfying this miniscript.

Source

pub fn context(&self) -> Context

Get the context this miniscript was parsed with.

Trait Implementations§

Source§

impl Debug for Miniscript

Source§

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

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

impl Drop for Miniscript

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Miniscript

Source§

impl Sync for Miniscript

Auto Trait Implementations§

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> 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<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, 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.