Refactor: move spending conditions implementation to nut10 module #1714
No reviewers
Labels
No labels
DB & Storage
Deployment
Error Handling & Logging
Maintenance
Payment Backend
backport
backport v0.13.x
backport v0.14.x
backport v0.15.x
bindings
blocked
bug
cdk-sql
ci
cli
deps
documentation
duplicate
enhancement
good first issue
help wanted
invalid
keep-open
ldk-node-ui
migrations
mint
mutation-testing
needs rebase
needs review
new nut
nut change
question
ready
rust-version
rustfmt
stacked hold
stale
testing
wallet
weekly-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cashubtc/cdk!1714
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "TheMhv/refact/spending_conditions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
SpendingConditionsimplementation is currently located innuts/nut11/mod.rs. However, spending conditions are defined in NUT-10, not NUT-11. Keeping this implementation undernut11can 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
nut10module so the code structure better reflects the specification layout.Notes to the reviewers
nut10/for module of NUT-10nut11/mod.rstonut10/spending_conditions.rsnut10/error.rsnut10/secret.rsSpendingConditions::new_p2pk,extract_signatures_from_witnessandverify_sig_all_p2pkfunctions tonut11/mod.rsSpendingConditions::new_htlc,SpendingConditions::new_htlc_hash,verify_htlc_preimageandverify_sig_all_htlctonut14/mod.rsTagandTagKindtonut10/tag.rsSuggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just final-checkbefore committingI 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?
@ -0,0 +1,45 @@//! Error types for NUT-10: Spending Conditionscosmetic verbiage update here
spend conditions not met, you currently havespend conditions not meetjust same verbiage change here
This moves some this to a better place but leaves other fns not in the files of their nut.
@ -0,0 +456,4 @@assert_eq!(original_secret, deserialized_secret);// Also verify that the conversion to crate::secret::Secret workslet cashu_secret = crate::secret::Secret::from_str(&serialized).unwrap();nut11?
Shouldn't these be in nut14
@ -0,0 +1,105 @@//! NUT-10 Secret ModuleThis makes the kind and secret data public where it was not before. I think we should keep it private.
@ -0,0 +1,341 @@//! NUT-10: Spending ConditionsShouldn't these but in nut14?
And this in nut11?
@ -0,0 +1,341 @@//! NUT-10: Spending ConditionsSure! But that will require more than a simple refactoring, going beyond the scope of this PR. We can separate this work into other PRs for better comprehension of each change.@ -0,0 +1,341 @@//! NUT-10: Spending ConditionsSame problem: https://github.com/cashubtc/cdk/pull/1714#discussion_r2918357575Looks 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
@ -250,9 +227,110 @@ impl Proof {}Since this is not intended to be called directly we can make it pub(crate).
@ -1076,7 +599,7 @@ mod tests {num_sigs_refund: None,These could be improved by using the Nut10Secret::new_p2pk() constructor
@ -217,6 +236,154 @@ impl Proof {}Since this is not intended to be called directly we can make it pub(crate).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.