Skip to content

fix(types): make nut08Change expressible and NUT-10 tags optional - #958

Merged
robwoodgate merged 1 commit into
v4-devfrom
fix/v4-align-config-types
Aug 12, 2026
Merged

fix(types): make nut08Change expressible and NUT-10 tags optional#958
robwoodgate merged 1 commit into
v4-devfrom
fix/v4-align-config-types

Conversation

@robwoodgate

Copy link
Copy Markdown
Collaborator

Description

Two public type corrections carried back from the v5 line (#955), shaped so that nothing is removed from this stable major. The point is partly the fixes themselves and partly keeping the two lines' type shapes aligned so future backports apply cleanly.

Changes

  • nut08Change moves onto MeltProofsConfig. meltProofs, meltProofsBolt11, meltProofsBolt12 and meltProofsOnchain all take MeltProofsConfig and forward it wholesale to prepareMelt, which took the wider PrepareMeltConfig. So the option already worked at runtime through every helper but could not be expressed in TypeScript. PrepareMeltConfig remains, as a deprecated alias of MeltProofsConfig, so no import breaks.
  • NUT10Option.tags and RawNUT10Option.t are optional. NUT-10 marks tags optional and NUT-18 describes t as "optional NUT-10 payment tags". The implementation already agreed: utils/tlv.ts declares its internal Nut10SpendingCondition.tags optional and deliberately returns undefined when absent, and every read site guards with ?? [] or a length check. Decoding a spec-valid request that omits tags therefore produced an object that violated its own declared type.

Reviewer Notes

  • Nothing is removed from the public surface. The API report diff is additive apart from the two fields becoming optional and PrepareMeltConfig collapsing to an alias.
  • The one compatibility wrinkle: TypeScript consumers who read nut10.tags now see string[][] | undefined and need a guard. That is the truth they were already exposed to at runtime, and PaymentRequestTransport.tags on this line is already optional, so it also removes an internal inconsistency.
  • In v5 PrepareMeltConfig is removed outright rather than aliased, which the v5 migration guide now records.
  • Verified on this branch: src/ type checks clean, node suite passes 62 files and 2077 tests, lint and format clean, api:update run and committed.

Aligns the v4 public types with v5 so future backports apply more cleanly,
without removing anything from this line.

- nut08Change moves onto MeltProofsConfig so it can be passed through the
  public melt helpers, not just prepareMelt. It already worked at runtime,
  since the helpers forward their config. PrepareMeltConfig stays as a
  deprecated alias
- NUT10Option.tags and RawNUT10Option.t are optional per NUT-10 and NUT-18.
  Every read site already guarded for it, and decoding a spec-valid request
  that omits tags produced an object that violated its own declared type
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v4-dev@ab51cda). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##             v4-dev     #958   +/-   ##
=========================================
  Coverage          ?   95.48%           
=========================================
  Files             ?       49           
  Lines             ?     5162           
  Branches          ?     1290           
=========================================
  Hits              ?     4929           
  Misses            ?      100           
  Partials          ?      133           
Flag Coverage Δ
integration 39.09% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robwoodgate
robwoodgate merged commit 34e2861 into v4-dev Aug 12, 2026
18 checks passed
@robwoodgate
robwoodgate deleted the fix/v4-align-config-types branch August 12, 2026 19:24
@github-project-automation github-project-automation Bot moved this from Backlog to Done in cashu-ts Aug 12, 2026
robwoodgate added a commit that referenced this pull request Aug 12, 2026
Mostly hardening fixes, a couple of minor breaking changes to note:

Experimental — SigAll (#951):
  
  1. SigAllDigests reshaped: { legacy, current } → { v0 }.
  2. SigAllSigningPackage.digests removed — digests are recomputed from package contents.
  3. deserializePackage(input, options?) → deserializePackage(input); the validateDigest option is gone, validation is now implicit.
  
  Stable, type-level (#958):
  
  4. NUT10Option.tags required → optional.
  5. RawNUT10Option.t required → optional. 
  
  Both only affect TypeScript consumers who read the field, who now see | undefined. Constructing gets easier, and it matches NUT-10 and NUT-18, which both call tags optional.
  
  Stable, behavioural (#932):
  
  6. New bolt11 quote-amount check that throws, at four call sites including the read paths checkMintQuoteBolt11 and
  checkMintQuoteBatchBolt11. Only affects non-compliant mints that return ln invoices that do not match the quote amounts, so should not break in practice.

Thanks to Project Loupe for suggesting some of the hardening fixes in this release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant