Skip to content

Refactor: move spending conditions implementation to nut10 module#1714

Open
TheMhv wants to merge 9 commits intocashubtc:mainfrom
TheMhv:refact/spending_conditions
Open

Refactor: move spending conditions implementation to nut10 module#1714
TheMhv wants to merge 9 commits intocashubtc:mainfrom
TheMhv:refact/spending_conditions

Conversation

@TheMhv
Copy link
Contributor

@TheMhv TheMhv commented Mar 7, 2026

Description

This PR moves the spending conditions implementation to the module that corresponds to the correct NUT specification.

While reviewing the code, I noticed that the SpendingConditions implementation is currently located in nuts/nut11/mod.rs. However, spending conditions are defined in NUT-10, not NUT-11. Keeping this implementation under nut11 can make the module structure slightly confusing for contributors trying to map code to the corresponding NUT specifications.

This change relocates the relevant implementation to the nut10 module so the code structure better reflects the specification layout.


Notes to the reviewers

  • Create a folder nut10/ for module of NUT-10
  • Move SpendingConditions and Conditions from nut11/mod.rs to nut10/spending_conditions.rs
  • Move all NUT-10 related errors to nut10/error.rs
  • Move Secret implementation to nut10/secret.rs
  • Move SpendingConditions::new_p2pk, extract_signatures_from_witness and verify_sig_all_p2pk functions to nut11/mod.rs
  • Move SpendingConditions::new_htlc, SpendingConditions::new_htlc_hash, verify_htlc_preimage and verify_sig_all_htlc to nut14/mod.rs
  • Move Tag and TagKind to nut10/tag.rs

Suggested CHANGELOG Updates

CHANGED

  • NUT-10 Spending Conditions

ADDED

REMOVED

FIXED


Checklist

@github-project-automation github-project-automation bot moved this to Backlog in CDK Mar 7, 2026
@TheMhv TheMhv force-pushed the refact/spending_conditions branch 4 times, most recently from 83adf76 to 3bc4f98 Compare March 9, 2026 15:22
@TheMhv TheMhv marked this pull request as ready for review March 9, 2026 16:46
@TheMhv TheMhv changed the title (WIP) Refactor: move spending conditions implementation to nut10 module Refactor: move spending conditions implementation to nut10 module Mar 9, 2026
@TheMhv
Copy link
Contributor Author

TheMhv commented Mar 9, 2026

I could further separate and modularize the Spending Conditions code, but that's not the purpose of this PR. What do you think about discussing this?

@TheMhv TheMhv force-pushed the refact/spending_conditions branch from 3bc4f98 to a2f73fc Compare March 9, 2026 18:28
Copy link
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

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

This moves some this to a better place but leaves other fns not in the files of their nut.

@github-project-automation github-project-automation bot moved this from Backlog to In progress in CDK Mar 11, 2026
@TheMhv TheMhv force-pushed the refact/spending_conditions branch 4 times, most recently from 977ee68 to 4c96fc0 Compare March 12, 2026 22:34
@TheMhv TheMhv force-pushed the refact/spending_conditions branch from 4c96fc0 to 93d1086 Compare March 12, 2026 22:35
@TheMhv TheMhv requested a review from thesimplekid March 12, 2026 22:38
@TheMhv TheMhv marked this pull request as draft March 13, 2026 11:41
@TheMhv TheMhv force-pushed the refact/spending_conditions branch from afde93c to 7c5c8ea Compare March 13, 2026 13:14
@TheMhv TheMhv marked this pull request as ready for review March 13, 2026 13:15
Copy link
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

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

Looks good. I think we should reduce the visibility of some of the helper fns we have so they are not in the public api. What do you think @crodas

@TheMhv TheMhv requested a review from thesimplekid March 14, 2026 00:59
@thesimplekid thesimplekid requested a review from crodas March 19, 2026 20:21
@thesimplekid thesimplekid added this to the 0.16.0 milestone Mar 19, 2026
@thesimplekid
Copy link
Collaborator

closes: #395

@thesimplekid thesimplekid linked an issue Mar 19, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Look at makeing this a trait and moving htlc out of 11

3 participants