Cashu: a keyset the mint stopped listing blocks every receive — repair it at connect until cdk#2702 ships
Maintainer thường phản hồi trong vòng 1 ngày
@Forte11Cuba đang làm issue này rồi.
Từ ngày 14/10/2026.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start in rust/src/cashu/wallet.rs at CashuWallet::connect, where the keyset repair would run before Wallet::new, and read the cdk#2702 trace to see how active flags are read back from the store. The done condition is the seam test in the issue: with two active sat keysets stored and the mint listing only one, active_keyset() picks the listed one. The UnknownKeySet mapping and Dart l10n are separate follow-ups, and the pin in docs/cashu/cdk-spike.md matters for the upstream dependency.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
After testnut.cashu.space was reset, the wallet could no longer receive any token from
it, valid ones included. A 12-sat token in the mint's current sat keyset, which cashu.me
redeemed fine, failed with "That token could not be redeemed. It may be from another mint, or
already spent." (CashuReceiveFailed). Neither cause was true.
The bug is in cdk and is reported upstream as cashubtc/cdk#2702. When a keyset disappears
from the mint's GET /v1/keysets (not marked inactive: gone), the wallet keeps it cached as
active: true. It can then be picked for the swap outputs, the mint answers 12001
(UnknownKeySet), and cdk's retry does not recover. This lasts until the local proof store is
edited by hand. A cdk release with the fix will take time, so this issue proposes a small
workaround in the app, plus the logging that was missing to diagnose it.
What happened, with evidence
- testnut now lists one
satkeyset (017bc604…) and oneusdkeyset, both
input_fee_ppk: 100. - The proof store (
cashu-<pubkey>.sqlite) still held the oldsatkeyset0184237e…with
active = 1, the same fee as the real one. The mint no longer lists it. - On a copy of that store, the app's own
CashuWallet::connectrefreshes keysets from the mint
(KeysetLoadPolicy::Refresh). Even after that,active_keyset()returned0184237e…
5 times out of 5. - Moving the store aside (fresh store, same identity, same mint) fixed it at once: the same
kind of token was received, less the mint's fee. - The 294 sat the wallet still showed were all proofs in
0184237e…, which the mint no longer
knows. The balance was phantom. - Finding this took a manual read of the SQLite store, because the app does not log why a
receive failed. cdk's error is reduced to a marker, Dart hides the tail (correctly), and no
log line keeps it.
Why it happens (cdk 0.18.1)
Full trace in cashubtc/cdk#2702. In short:
fetch_from_httpstarts from the cached metadata and only inserts what the mint returns. A
keyset missing from the response keeps its storedactiveflag, which is written back to
the store.Wallet::keysets()reads those flags, andactive_keyset()takes the cheapest active one.
On a fee tie it depends onHashMaporder.retry_on_inactive_keysetmatches onlyInactiveKeyset, so a12001is not retried.
Scope in production
NUT-02 has a mint keep listing rotated keysets as active: false. cdk then updates the flag
correctly, so a normal key rotation is fine. This only bites when a mint drops keysets from
its list: a test mint reset, or a mint that lost or replaced its database. That is rare, but
when it happens the wallet is stuck with a false message and a balance it cannot spend.
Proposal
All verified against the public API of cdk 0.18.1:
Wallet::localstoreispub;cdk::wallet::HttpClientandMintConnector::get_mint_keysetsare public;- cdk-sqlite's keyset upsert updates
active(ON CONFLICT(id) DO UPDATE SET active = excluded.active); Wallet::newbuilds a fresh metadata cache, whose first load reads the store before refreshing from the mint (mint_metadata_cache.rs,load_from_mint).
1. Repair the store at connect (rust/src/cashu/wallet.rs, CashuWallet::connect, before
Wallet::new):
- fetch the mint's keyset list with
HttpClient(one extraGET /v1/keysets; the wallet
opens lazily, never at startup); - read the stored keysets of that mint (
localstore.get_mint_keysets); - write back with
active: falseevery stored keyset marked active that the mint no longer
lists (add_mint_keysets), skippingauthkeysets, whose list is not fetched.
Nothing is deleted. If the mint lists the keyset again, the next refresh makes it active again.
If the mint does not answer, the repair is skipped and probe fails with
CashuMintUnreachable as today. As a side effect, MintCapabilities::has_sat_keyset stops
counting a dead keyset.
2. A mint reset while the app is open. When an operation fails with
cdk::Error::UnknownKeySet:
- drop the live wallet, so the next action reconnects and repairs;
- return a stable marker, e.g.
CashuMintKeysetsChanged, which Dart maps to "The mint
changed its keys. Try again." (l10n in every locale).
No automatic retry: the mint rejects the whole swap, so a retry would be safe, but it adds
complexity for a rare case.
3. Log the real error. log::warn! the cdk error in cashu_receive_token,
cashu_create_token and cashu_sweep_spent_proofs before it becomes a marker. This stays
useful whatever happens upstream.
4. Remove the workaround when cdk ships the fix. Leave a comment pointing to
cashubtc/cdk#2702 on the repair. When the pin moves past the release that fixes it
(docs/cashu/cdk-spike.md), delete the repair and keep its test.
Tests
- Seam test (fails without the repair): use a temporary
WalletSqliteDatabase, as
stored_balancedoes. Store twosatkeysets marked active. Apply the repair with a mint
list that contains only one of them. Build theWalletand assert thatactive_keyset()
picks the listed one. Without the repair, the same setup returns the dead keyset, as the
test in cdk#2702 shows. - Unit tests for the selection: a missing keyset is deactivated; a listed one is
untouched; an already inactive one is untouched; anauthkeyset is left alone. - Mapping test:
UnknownKeySet→CashuMintKeysetsChanged, and the live wallet is
dropped. - Manual: the store from this report (kept aside) reproduces it. With the repair, a sat
token from the mint's current keyset is received on that store.
Out of scope
- The phantom balance. Proofs in a keyset the mint no longer lists are worthless, but the
balance still counts them. Excluding them and saying so ("N sat are in keys this mint no
longer recognises") is a separate UX decision. The proofs are not deleted, in case the mint
comes back. - #391 / #798. Tokens in a unit other than sats are a different bug.
References
- Upstream: cashubtc/cdk#2702
- Found while testing #798 (#391)
- cdk / cdk-sqlite pinned at
=0.18.1
- Ngôn ngữ chính
- Dart
- Star
- 11
- Fork
- 9
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MostroP2P/app
-
documentation priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: ui bug priority: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
NWC: the pay and buyer-invoice readouts are zero-size, so no accessibility tree carries themĐang mởarea: ui bug priority: high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: Button "Share logs" does nothingCó thể đã có người làm @Luquitasjeffrey đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: rust-core bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MostroP2P/app
Issue tương tự
-
Python example: list a model's scenes and their camerasCó thể đã có người làm @rudraparmar76 đã nhận hôm nay. Đang mởdocumentation good first issue python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
iamahsanmehmood/openskp#796 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Plural rendering: first matching part wins, but gen-l10n lets the last one win (=1 shadows one)Đang mởbug help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
crowdin/flutter-sdk#97 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
MrSpideyNihal/lockfeed#16 ·
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
InlitX/GymMane#529 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày