Skip to content

feat: output verification using custom tags#3

Merged
YofiY merged 5 commits intofeature/spending-conditionsfrom
output-verification
Aug 2, 2025
Merged

feat: output verification using custom tags#3
YofiY merged 5 commits intofeature/spending-conditionsfrom
output-verification

Conversation

@vincentpalma
Copy link

To consider: maybe what we call output in the tags should be renamed output_hash and we could add another tag output of type Vec<Vec> that encodes the output directly (would be [0x1] in the test example) and users could choose one or another depending on use cases.

@vincentpalma vincentpalma requested a review from YofiY July 31, 2025 19:04

for tag in tags {
if tag.len() < 2 {
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

an error should be thrown

Copy link
Author

Choose a reason for hiding this comment

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

I think its better not to throw. It will anyways never happen but its not the responsibility of this function to check this for every tag.

type Error = Error;
fn try_from(tags: Vec<Vec<String>>) -> Result<Conditions, Self::Error> {
let mut output = None;

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be cleaner to use a create a HashMap<TagKind, Tag> as done for the analoguous fn for P2PK in nut11

        let tags: HashMap<TagKind, Tag> = tags
            .into_iter()
            .map(|t| Tag::try_from(t).unwrap())
            .map(|t| (t.kind(), t))
            .collect();

and then match on each supported tag kind:
i.e. for output_hash

let output_hash = match tags.get(&TagKind::Custom(...))...

Copy link
Author

Choose a reason for hiding this comment

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

The problem is that Tag is defined for the conditions of nut11, which we don't care about, and adding a new Tag to nut11 is not the right thing to do if we can avoid it imo.

Copy link
Collaborator

@YofiY YofiY left a comment

Choose a reason for hiding this comment

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

lgtm

@YofiY YofiY merged commit e4fd4e7 into feature/spending-conditions Aug 2, 2025
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.

2 participants