Commit a95a61a
bg002h
descriptor: expose WalletPolicy template + key_info accessors
The internal `template: Descriptor<KeyExpression>` and
`key_info: Vec<DescriptorPublicKey>` fields are needed by external
consumers that need to inspect a `WalletPolicy`'s placeholder structure
without consuming the policy via `into_descriptor()`.
The motivating case is multipath-shared `@N` placeholders — e.g.
`sh(multi(1,@0/**,@0/<2;3>/*))`, where the same placeholder appears at
two distinct AST positions. After `into_descriptor()` the placeholder
labels are erased and the materialized descriptor surfaces two separate
keys; the template preserves placeholder identity via the public
`KeyExpression::index` field. Encoders and other consumers that need
the `(AST position) -> (placeholder index)` mapping have no public way
to obtain it today.
Adds two read accessors on `WalletPolicy`:
- `pub fn template(&self) -> &Descriptor<KeyExpression>` — yields the
template; iterating gives `(AST position, KeyExpression)` pairs and
the placeholder index is `ke.index.0`.
- `pub fn key_info(&self) -> &[DescriptorPublicKey]` — yields the
key-information vector (symmetric with the existing
`set_key_info(&mut self, ...)`).
Re-exports `KeyExpression` and `KeyIndex` at
`miniscript::descriptor::*` so the new return type is namable from
outside the crate, and adds rustdoc to `KeyIndex` and
`KeyExpression::is_disjoint` (now reachable via the re-exports;
required by the crate's missing_docs lint).
Internal `validate()` already uses `self.template.iter_pk()` the same
way external callers will; this commit just makes the access pattern
available on the public API.1 parent f7f1689 commit a95a61a
3 files changed
Lines changed: 77 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
111 | 131 | | |
112 | 132 | | |
113 | 133 | | |
| |||
377 | 397 | | |
378 | 398 | | |
379 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
380 | 452 | | |
0 commit comments