Descriptor Trait/Typeclass:
Table of API on along the rows, and columns showing the descriptor type. Each box represents
- y = always succeeds
- n = always fails
- yn = may succeed
All descriptors sh/wsh/shwsh/tr/bare support miniscript descriptors
| let ms = match desc { | |
| Descriptor::Sh(ref sh) => { | |
| match sh.as_inner(){ | |
| ShInner::Wsh(wsh ) => { | |
| match wsh.as_inner() { | |
| WshInner::Ms(ref ms) => ms | |
| } | |
| } | |
| } | |
| } |
| error[E0308]: mismatched types | |
| --> src/test_random_miniscripts.rs:32:44 | |
| | | |
| 32 | let ms: Result<_, ()> = ms.translate_pk( | |
| | ^^^^^^^^^^^^ one type is more general than the other | |
| | | |
| = note: expected type `FnOnce<(&std::string::String,)>` | |
| found type `FnOnce<(&std::string::String,)>` |
| // Miniscript | |
| // Written in 2018 by | |
| // Andrew Poelstra <[email protected]> | |
| // | |
| // To the extent possible under law, the author(s) have dedicated all | |
| // copyright and related and neighboring rights to this software to | |
| // the public domain worldwide. This software is distributed without | |
| // any warranty. | |
| // | |
| // You should have received a copy of the CC0 Public Domain Dedication |
| fn witness_script<ToPkCtx: Copy>(&self, to_pk_ctx: ToPkCtx) -> BtcScript | |
| where | |
| Pk: ToPublicKey<ToPkCtx>, | |
| { | |
| let tweak = self.desc.witness_script(to_pk_ctx).into_bytes(); | |
| let mut builder = script::Builder::new() | |
| .push_opcode(opcodes::all::OP_DEPTH) | |
| .push_int(self.fed_k as i64 + 1) | |
| .push_opcode(opcodes::all::OP_EQUAL) |
| def normalize(sign, v, modulus): | |
| """Compute sign*v mod modulus, where v in (-2*modulus,modulus); output in [0,modulus).""" | |
| ans = (sign*v) % modulus | |
| v += modulus & (v >> 256) # I think this line is wrong when v has 257th bit set and 256 unset | |
| c = (sign - 1) >> 1 | |
| v = (v ^ c) - c | |
| v += modulus & (v >> 256) | |
| assert ans == (v % modulus), print(ans, v) | |
| return v |
| Descriptor{ | |
| Sh(ShInner), | |
| Wsh(WshInner), | |
| Bare(Miniscript), | |
| Pk, | |
| Pkh, | |
| Wpkh, | |
| } |
| #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] | |
| pub struct SortedMultiVec<Pk: MiniscriptKey, Ctx: ScriptContext>{ | |
| /// public keys inside sorted Multi | |
| pub pks: Vec<Pk>, | |
| /// The current ScriptContext for sortedmulti | |
| pub(crate) phantom: PhantomData<Ctx> | |
| } | |
| impl SortedMultiVec{ | |
| fn new(pks: &[Pk]) -> Result<Self, Error>{ |
| pub trait ScriptContext: | |
| fmt::Debug + Clone + Ord + PartialOrd + Eq + PartialEq + private::Sealed | |
| { | |
| /// Depending on ScriptContext, fragments can be malleable. For Example, | |
| /// under Legacy context, PkH is malleable because it is possible to | |
| /// estimate the cost of satisfaction because of compressed keys | |
| /// This is currently only used in compiler code for removing malleable | |
| /// compilations. | |
| /// This does NOT recursively check if the children of the fragment are | |
| /// valid or not. Since the compilation proceeds in a leaf to root fashion, |
TODO: Rust-miniscript behaviour for resource limitations:
This document refers to bitcoin consensus and standardness rules as of bitcoin core release 0.20.
One of miniscript’s goals are to make advanced Script functionality accommodate both machine and human analysis. However such a analysis is not possible in all cases.
B, or thresh must have all of it's arguments being dissatifyable.