@@ -29,6 +29,9 @@ use crate::miniscript::types::extra_props::TimelockInfo;
29
29
use crate :: prelude:: * ;
30
30
use crate :: { errstr, Error , ForEachKey , MiniscriptKey , Translator } ;
31
31
32
+ #[ cfg( all( doc, not( feature = "compiler" ) ) ) ]
33
+ use crate :: Descriptor ;
34
+
32
35
/// Maximum TapLeafs allowed in a compiled TapTree
33
36
#[ cfg( feature = "compiler" ) ]
34
37
const MAX_COMPILATION_LEAVES : usize = 1024 ;
@@ -207,18 +210,18 @@ pub enum PolicyError {
207
210
DuplicatePubKeys ,
208
211
}
209
212
210
- /// Descriptor context for [`Policy`] compilation into a [`Descriptor`]
213
+ /// Descriptor context for [`Policy`] compilation into a [`Descriptor`].
211
214
pub enum DescriptorCtx < Pk > {
212
- /// [Bare][ `Descriptor::Bare`]
215
+ /// See docs for [ `Descriptor::Bare`].
213
216
Bare ,
214
- /// [Sh][ `Descriptor::Sh`]
217
+ /// See docs for [ `Descriptor::Sh`].
215
218
Sh ,
216
- /// [Wsh][ `Descriptor::Wsh`]
219
+ /// See docs for [ `Descriptor::Wsh`].
217
220
Wsh ,
218
- /// Sh-wrapped [Wsh][ `Descriptor::Wsh`]
221
+ /// See docs for [ `Descriptor::Wsh`].
219
222
ShWsh ,
220
- /// [Tr][ `Descriptor::Tr`] where the Option<Pk> corresponds to the internal_key if no internal
221
- /// key can be inferred from the given policy
223
+ /// [`Descriptor::Tr`] where the ` Option<Pk>` corresponds to the internal key if no
224
+ /// internal key can be inferred from the given policy.
222
225
Tr ( Option < Pk > ) ,
223
226
}
224
227
@@ -364,7 +367,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
364
367
}
365
368
}
366
369
367
- /// Compile the [`Policy`] into a [`Tr`][` Descriptor::Tr`] Descriptor .
370
+ /// Compile the [`Policy`] into a [`Descriptor::Tr`].
368
371
///
369
372
/// ### TapTree compilation
370
373
///
@@ -417,20 +420,26 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
417
420
}
418
421
}
419
422
420
- /// Compile the [`Policy`] into a [`Tr`][`Descriptor::Tr`] Descriptor, with policy-enumeration
421
- /// by [`Policy::enumerate_policy_tree`].
423
+ /// Compiles the [`Policy`] into a [`Descriptor::Tr`].
422
424
///
423
425
/// ### TapTree compilation
424
426
///
425
- /// The policy tree constructed by root-level disjunctions over [`Or`][` Policy::Or`] and
426
- /// [`Thresh`][` Policy::Threshold`](k, ..n..) which is flattened into a vector (with respective
427
- /// probabilities derived from odds) of policies.
428
- /// For example, the policy `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the vector
427
+ /// The policy tree constructed by root-level disjunctions over [`Policy::Or`] and
428
+ /// [`Policy::Threshold`] (k, ..n..) which is flattened into a vector (with respective
429
+ /// probabilities derived from odds) of policies. For example, the policy
430
+ /// `thresh(1,or(pk(A),pk(B)),and(or(pk(C),pk(D)),pk(E)))` gives the vector
429
431
/// `[pk(A),pk(B),and(or(pk(C),pk(D)),pk(E)))]`.
430
432
///
431
433
/// ### Policy enumeration
432
434
///
433
- /// Refer to [`Policy::enumerate_policy_tree`] for the current strategy implemented.
435
+ /// Generates a root-level disjunctive tree over the given policy tree.
436
+ ///
437
+ /// Uses a fixed-point algorithm to enumerate the disjunctions until exhaustive root-level
438
+ /// enumeration or limits exceed. For a given [`Policy`], we maintain an [ordered
439
+ /// set](`BTreeSet`) of `(prob, policy)` (ordered by probability) to maintain the list of
440
+ /// enumerated sub-policies whose disjunction is isomorphic to initial policy (*invariant*).
441
+ ///
442
+ /// [`Policy`]: crate::policy::concrete::Policy
434
443
#[ cfg( feature = "compiler" ) ]
435
444
pub fn compile_tr_private_experimental (
436
445
& self ,
@@ -537,12 +546,14 @@ impl<Pk: MiniscriptKey> PolicyArc<Pk> {
537
546
}
538
547
}
539
548
540
- /// Generates a root-level disjunctive tree over the given policy tree, by using fixed-point
541
- /// algorithm to enumerate the disjunctions until exhaustive root-level enumeration or limits
542
- /// exceed.
543
- /// For a given [policy][`Policy`], we maintain an [ordered set][`BTreeSet`] of `(prob, policy)`
544
- /// (ordered by probability) to maintain the list of enumerated sub-policies whose disjunction
545
- /// is isomorphic to initial policy (*invariant*).
549
+ /// Generates a root-level disjunctive tree over the given policy tree.
550
+ ///
551
+ /// Uses a fixed-point algorithm to enumerate the disjunctions until exhaustive root-level
552
+ /// enumeration or limits exceed. For a given [`Policy`], we maintain an [ordered
553
+ /// set](`BTreeSet`) of `(prob, policy)` (ordered by probability) to maintain the list of
554
+ /// enumerated sub-policies whose disjunction is isomorphic to initial policy (*invariant*).
555
+ ///
556
+ /// [`Policy`]: crate::policy::concrete::Policy
546
557
#[ cfg( feature = "compiler" ) ]
547
558
fn enumerate_policy_tree ( self , prob : f64 ) -> Vec < ( f64 , Arc < Self > ) > {
548
559
let mut tapleaf_prob_vec = BTreeSet :: < ( Reverse < OrdF64 > , Arc < Self > ) > :: new ( ) ;
0 commit comments