Commit 0a2d69d
committed
d12cf6c Add translate_pk method to confidential descriptors (Velnbur)
Pull request description:
The reasoning behind this PR is a small enhancement in developer experience. `miniscript::Descriptor` has [`translate_pk`](https://docs.rs/miniscript/latest/miniscript/descriptor/enum.Descriptor.html#method.translate_pk) method, but [`ConfidentialDescriptor`](https://docs.rs/elements-miniscript/latest/elements_miniscript/confidential/struct.Descriptor.html) does not. Because of this, to translate the inner descriptor, the user needs to extract it and then move the key:
```rust
let conf_descriptor = ConfidentialDescriptor::<DescriptorPublicKey>::from_str(&descriptor_str).unwrap();
let definite_desc = conf_descriptor
.descriptor
.translate_pk(&mut translator)
.unwrap();
let definite_conf_descriptor = ConfidentialDescriptor {
descriptor: definite_desc,
key: conf_descriptor.key,
};
definite_conf_descriptor.address(SECP256K1, &AddressParams::LIQUID)
```
When in `miniscript`, this can be done with method chain calls:
```rust
let descriptor = Descriptor::<DescriptorPublicKey>::from_str(&wallet.descriptor).unwrap();
descriptor
.translate_pk(&mut translator)
.unwrap()
.address(Network::Bitcoin)
```
ACKs for top commit:
apoelstra:
ACK d12cf6c; successfully ran local tests; yeah, this seems useful, though I wish we had a more elegant way to treat blinding keys like descriptor keys
Tree-SHA512: eba5e5219332b2faf55acfe3eb774ea280234ec842c1abdac2b417d264363710fd79ddbb8b6b863cce4e576067f005a1eaf39edc8102c9f33d8d7ee94d228d2b
2 files changed
Lines changed: 68 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
169 | 186 | | |
170 | 187 | | |
171 | 188 | | |
| |||
330 | 347 | | |
331 | 348 | | |
332 | 349 | | |
333 | | - | |
334 | 350 | | |
335 | 351 | | |
336 | 352 | | |
| |||
0 commit comments