[−]Struct bdk::descriptor::Miniscript
Top-level script AST type
Fields
node: Terminal<Pk, Ctx>
A node in the Abstract Syntax Tree(
ty: Type
The correctness and malleability type information for the AST node
ext: ExtData
Additional information helpful for extra analysis.
Implementations
impl<Pk, Ctx> Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
pub fn from_ast(t: Terminal<Pk, Ctx>) -> Result<Miniscript<Pk, Ctx>, Error>
Add type information(Type and Extdata) to Miniscript based on
AstElem
fragment. Dependent on display and clone because of Error
Display code of type_check.
impl<Pk, Ctx> Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
pub fn into_inner(self) -> Terminal<Pk, Ctx>
Extracts the AstElem
representing the root of the miniscript
pub fn as_inner(&self) -> &Terminal<Pk, Ctx>
impl<Ctx> Miniscript<PublicKey, Ctx> where
Ctx: ScriptContext,
Ctx: ScriptContext,
pub fn parse(script: &Script) -> Result<Miniscript<PublicKey, Ctx>, Error>
Attempt to parse a script into a Miniscript representation
impl<Pk, Ctx> Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey + ToPublicKey,
Ctx: ScriptContext,
Pk: MiniscriptKey + ToPublicKey,
pub fn encode(&self) -> Script
Encode as a Bitcoin script
pub fn script_size(&self) -> usize
Size, in bytes of the script-pubkey. If this Miniscript is used outside of segwit (e.g. in a bare or P2SH descriptor), this quantity should be multiplied by 4 to compute the weight.
In general, it is not recommended to use this function directly, but
to instead call the corresponding function on a Descriptor
, which
will handle the segwit/non-segwit technicalities for you.
pub fn max_satisfaction_witness_elements(&self) -> usize
Maximum number of witness elements used to satisfy the Miniscript
fragment, including the witness script itself. Used to estimate
the weight of the VarInt
that specifies this number in a serialized
transaction.
This function may panic on misformed Miniscript
objects which do
not correspond to semantically sane Scripts. (Such scripts should be
rejected at parse time. Any exceptions are bugs.)
pub fn max_satisfaction_size(&self, one_cost: usize) -> usize
Maximum size, in bytes, of a satisfying witness. For Segwit outputs
one_cost
should be set to 2, since the number 1
requires two
bytes to encode. For non-segwit outputs one_cost
should be set to
1, since OP_1
is available in scriptSigs.
In general, it is not recommended to use this function directly, but
to instead call the corresponding function on a Descriptor
, which
will handle the segwit/non-segwit technicalities for you.
All signatures are assumed to be 73 bytes in size, including the length prefix (segwit) or push opcode (pre-segwit) and sighash postfix.
This function may panic on misformed Miniscript
objects which do not
correspond to semantically sane Scripts. (Such scripts should be
rejected at parse time. Any exceptions are bugs.)
impl<Pk, Ctx> Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
pub fn translate_pk<FPk, FPkh, Q, FuncError>(
&self,
translatefpk: &mut FPk,
translatefpkh: &mut FPkh
) -> Result<Miniscript<Q, Ctx>, FuncError> where
FPk: FnMut(&Pk) -> Result<Q, FuncError>,
FPkh: FnMut(&<Pk as MiniscriptKey>::Hash) -> Result<<Q as MiniscriptKey>::Hash, FuncError>,
Q: MiniscriptKey,
&self,
translatefpk: &mut FPk,
translatefpkh: &mut FPkh
) -> Result<Miniscript<Q, Ctx>, FuncError> where
FPk: FnMut(&Pk) -> Result<Q, FuncError>,
FPkh: FnMut(&<Pk as MiniscriptKey>::Hash) -> Result<<Q as MiniscriptKey>::Hash, FuncError>,
Q: MiniscriptKey,
This will panic if translatefpk returns an uncompressed key when converting to a Segwit descriptor. To prevent this panic, ensure translatefpk returns an error in this case instead.
impl<Pk, Ctx> Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey + ToPublicKey,
Ctx: ScriptContext,
Pk: MiniscriptKey + ToPublicKey,
pub fn satisfy<S>(&self, satisfier: S) -> Option<Vec<Vec<u8>>> where
S: Satisfier<Pk>,
S: Satisfier<Pk>,
Attempt to produce a satisfying witness for the witness script represented by the parse tree
Trait Implementations
impl<Pk, Ctx> Clone for Miniscript<Pk, Ctx> where
Ctx: ScriptContext + Clone,
Pk: MiniscriptKey + Clone,
Ctx: ScriptContext + Clone,
Pk: MiniscriptKey + Clone,
fn clone(&self) -> Miniscript<Pk, Ctx>
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Pk, Ctx> Debug for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
impl<Pk, Ctx> Display for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
impl<Pk, Ctx> Eq for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
Eq
of Miniscript
must depend only on node and not the type information.
The type information and extra_properties can be deterministically determined
by the ast.
impl<Ctx: ScriptContext> ExtractPolicy for Miniscript<DescriptorPublicKey, Ctx>
[src]
fn extract_policy(
&self,
signers: Arc<SignersContainer<DescriptorPublicKey>>
) -> Result<Option<Policy>, Error>
[src]
&self,
signers: Arc<SignersContainer<DescriptorPublicKey>>
) -> Result<Option<Policy>, Error>
impl<Pk, Ctx> FromStr for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
Ctx: ScriptContext,
Pk: MiniscriptKey,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Miniscript<Pk, Ctx>, Error>
impl<Pk, Ctx> FromTree for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
Ctx: ScriptContext,
Pk: MiniscriptKey,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
fn from_tree(top: &Tree) -> Result<Miniscript<Pk, Ctx>, Error>
Parse an expression tree into a Miniscript. As a general rule, this should not be called directly; rather go through the descriptor API.
impl<Pk, Ctx> Hash for Miniscript<Pk, Ctx> where
Ctx: ScriptContext + Hash,
Pk: MiniscriptKey + Hash,
Ctx: ScriptContext + Hash,
Pk: MiniscriptKey + Hash,
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<Pk, Ctx> Liftable<Pk> for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
fn lift(&self) -> Policy<Pk>
impl<Pk, Ctx> Ord for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ord
of Miniscript
must depend only on node and not the type information.
The type information and extra_properties can be deterministically determined
by the ast.
fn cmp(&self, other: &Miniscript<Pk, Ctx>) -> Ordering
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<Pk, Ctx> PartialEq<Miniscript<Pk, Ctx>> for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
PartialEq
of Miniscript
must depend only on node and not the type information.
The type information and extra_properties can be deterministically determined
by the ast.
fn eq(&self, other: &Miniscript<Pk, Ctx>) -> bool
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<Pk, Ctx> PartialOrd<Miniscript<Pk, Ctx>> for Miniscript<Pk, Ctx> where
Ctx: ScriptContext,
Pk: MiniscriptKey,
Ctx: ScriptContext,
Pk: MiniscriptKey,
PartialOrd
of Miniscript
must depend only on node and not the type information.
The type information and extra_properties can be deterministically determined
by the ast.
Auto Trait Implementations
impl<Pk, Ctx> RefUnwindSafe for Miniscript<Pk, Ctx> where
Ctx: RefUnwindSafe,
Pk: RefUnwindSafe,
<Pk as MiniscriptKey>::Hash: RefUnwindSafe,
Ctx: RefUnwindSafe,
Pk: RefUnwindSafe,
<Pk as MiniscriptKey>::Hash: RefUnwindSafe,
impl<Pk, Ctx> Send for Miniscript<Pk, Ctx> where
Ctx: Send + Sync,
Pk: Send + Sync,
<Pk as MiniscriptKey>::Hash: Send + Sync,
Ctx: Send + Sync,
Pk: Send + Sync,
<Pk as MiniscriptKey>::Hash: Send + Sync,
impl<Pk, Ctx> Sync for Miniscript<Pk, Ctx> where
Ctx: Send + Sync,
Pk: Send + Sync,
<Pk as MiniscriptKey>::Hash: Send + Sync,
Ctx: Send + Sync,
Pk: Send + Sync,
<Pk as MiniscriptKey>::Hash: Send + Sync,
impl<Pk, Ctx> Unpin for Miniscript<Pk, Ctx> where
Ctx: Unpin,
Pk: Unpin,
<Pk as MiniscriptKey>::Hash: Unpin,
Ctx: Unpin,
Pk: Unpin,
<Pk as MiniscriptKey>::Hash: Unpin,
impl<Pk, Ctx> UnwindSafe for Miniscript<Pk, Ctx> where
Ctx: RefUnwindSafe + UnwindSafe,
Pk: RefUnwindSafe + UnwindSafe,
<Pk as MiniscriptKey>::Hash: RefUnwindSafe + UnwindSafe,
Ctx: RefUnwindSafe + UnwindSafe,
Pk: RefUnwindSafe + UnwindSafe,
<Pk as MiniscriptKey>::Hash: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,