feat: output verification using custom tags#3
Merged
YofiY merged 5 commits intofeature/spending-conditionsfrom Aug 2, 2025
Merged
feat: output verification using custom tags#3YofiY merged 5 commits intofeature/spending-conditionsfrom
YofiY merged 5 commits intofeature/spending-conditionsfrom
Conversation
YofiY
requested changes
Aug 2, 2025
|
|
||
| for tag in tags { | ||
| if tag.len() < 2 { | ||
| continue; |
Author
There was a problem hiding this comment.
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; | ||
|
|
Collaborator
There was a problem hiding this comment.
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(...))...
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.