From b0b75e06079a0ce816f9ba281ecd38949b433ff9 Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Tue, 14 Jul 2026 14:35:11 +0200 Subject: [PATCH] Bump cashu-ts to 4.7.1 and drop the onchain counter workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 4.7.1 fixes the defect we routed around: mintProofsOnchain (and mintProofsBolt12) narrowed their config to {keysetId} and so silently dropped onCountersReserved — the callback that reports which derivation indices the library consumed. Without it our keyset counter would desync and risk blinded-secret reuse, so mintOnchainProofs called the generic mintProofs('onchain', ...) instead, which took the full MintProofsConfig. 4.7.1 widens the config on both helpers to Omit (cashubtc/cashu-ts#784), so the typed helper now carries the callback and the workaround is unnecessary. Reverted to mintProofsOnchain(amount, quote, privkey, config). That this typechecks is itself the check: under 4.7.0 passing onCountersReserved to that config was an excess-property error. 260/260 tests pass; typecheck introduces no new errors. Co-Authored-By: Claude Opus 4.8 --- package.json | 2 +- src/models/WalletStore.ts | 27 ++++++++------------------- yarn.lock | 10 +++++----- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index c95f1d0a..c918aea4 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "machine-translate": "npx @inlang/cli machine translate --project minibits.inlang" }, "dependencies": { - "@cashu/cashu-ts": "^4.7.0", + "@cashu/cashu-ts": "^4.7.1", "@fortawesome/fontawesome-svg-core": "^7.1.0", "@fortawesome/free-brands-svg-icons": "^7.1.0", "@fortawesome/free-regular-svg-icons": "^7.1.0", diff --git a/src/models/WalletStore.ts b/src/models/WalletStore.ts index 12cf9fe7..6e7764eb 100644 --- a/src/models/WalletStore.ts +++ b/src/models/WalletStore.ts @@ -920,23 +920,13 @@ export const WalletStoreModel = types /** * Mint ecash against a confirmed onchain deposit. * - * Mirrors `mintProofs` (same counter discipline, same NUT-19 in-flight - * record, same error surface) with two differences: + * Mirrors `mintProofs`: same counter discipline, same NUT-19 in-flight record, + * same error surface. * - * - it goes through the GENERIC `mintProofs('onchain', ...)` rather than - * the `mintProofsOnchain` sugar. The sugar takes a narrowed config of - * just `{keysetId}` — it silently drops `onCountersReserved`, which is - * how we learn which derivation indices the library actually consumed. - * Losing that would desync our counter and risk blinded-secret reuse. - * The generic form takes the full MintProofsConfig, which carries BOTH - * `privkey` and `onCountersReserved`. - * - * - `quote` is the whole MintQuoteOnchainResponse, not an id. cashu-ts - * signs the request (NUT-20) when the quote carries a `pubkey`, and it - * reads that off the quote object. - * - * `privkey` is derived on demand from the seed and the quote's stored - * counterIndex; it is never persisted. + * `quote` is the whole MintQuoteOnchainResponse, not an id — cashu-ts signs the + * request (NUT-20) when the quote carries a `pubkey`, and it reads that off the + * quote object. `privkey` is derived on demand from the seed and the quote's + * stored counterIndex; it is never persisted. */ mintOnchainProofs: flow(function* mintOnchainProofs( mintUrl: string, @@ -995,13 +985,12 @@ export const WalletStoreModel = types let reservedCounters: OperationCounters | undefined try { - const proofs = yield cashuWallet.mintProofs( - 'onchain', + const proofs = yield cashuWallet.mintProofsOnchain( mintParams.amount, quoteResponse, + privkey, { keysetId: mintParams.options?.keysetId, - privkey, onCountersReserved: (info: OperationCounters) => { reservedCounters = info log.debug('[mintOnchainProofs] Counters reserved', info) diff --git a/yarn.lock b/yarn.lock index f8cc192f..f882d881 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2869,15 +2869,15 @@ __metadata: languageName: node linkType: hard -"@cashu/cashu-ts@npm:^4.7.0": - version: 4.7.0 - resolution: "@cashu/cashu-ts@npm:4.7.0" +"@cashu/cashu-ts@npm:^4.7.1": + version: 4.7.1 + resolution: "@cashu/cashu-ts@npm:4.7.1" dependencies: "@noble/curves": ^2.2.0 "@noble/hashes": ^2.2.0 "@scure/base": ^2.2.0 "@scure/bip32": ^2.2.0 - checksum: 006f3dea45ceb6920b0d555e3b567576ee0fa9b48024110323101d26e57bc31a4c0157f6ab642cb0b185395999b262b1ecb6f70d05cf7ccb9560943a4f652159 + checksum: c8dfb7afd37835f0a79e30cc3e4f0fe70cafbd2670aa6674a978749ecec19c0d8e34597959cc05b96b9663f9ca9803bfd78efcc1d295e7b5e0f3a59c75875477 languageName: node linkType: hard @@ -14823,7 +14823,7 @@ __metadata: "@babel/plugin-proposal-export-namespace-from": ^7.18.9 "@babel/preset-env": ^7.25.3 "@babel/runtime": ^7.25.0 - "@cashu/cashu-ts": ^4.7.0 + "@cashu/cashu-ts": ^4.7.1 "@expo/fingerprint": ^0.13.4 "@fortawesome/fontawesome-svg-core": ^7.1.0 "@fortawesome/free-brands-svg-icons": ^7.1.0