Skip to content

Add Descriptor::iter_pk #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add Descriptor::iter_pk #823

wants to merge 2 commits into from

Conversation

apoelstra
Copy link
Member

Fixes #821.

Should backport to 12.x.

This commit was -not- AI-generated, though probably it should've been.
@apoelstra apoelstra force-pushed the push-slnpvpouumpw branch 2 times, most recently from d3fab75 to 82f86e1 Compare May 23, 2025 23:31
This one -was- AI-generated, though I reviewed it.
@apoelstra apoelstra force-pushed the push-slnpvpouumpw branch from 82f86e1 to aa42cd3 Compare May 23, 2025 23:36
Copy link
Member Author

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On aa42cd3 successfully ran local tests

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question. Rest LGTM

use crate::{miniscript, Miniscript, MiniscriptKey};

/// Iterator over all the keys in a descriptor.
pub struct PkIter<'desc, Pk: MiniscriptKey> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. But Ideally, we want this to be a sum type instead of a product type? But then we get whole loads of matches everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason to use a product type was that Taproot descriptors have both single keys and (optionally) a taptree iterator.

And in PkIter::next I have a construction where the taptree iterator yields new Miniscript pkiters.

I can try to refactor this to use a sum type but I think it would result in more repeated/redundant code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Descriptor::iter_pk()
2 participants