Fix restore bug: all proofs had same secret; convert to streaming API#413
Merged
1-leo merged 10 commits intocashu-walletfrom Feb 5, 2026
Merged
Fix restore bug: all proofs had same secret; convert to streaming API#4131-leo merged 10 commits intocashu-walletfrom
1-leo merged 10 commits intocashu-walletfrom
Conversation
- Added restore endpoint to CashuRepo interface - Implemented restore endpoint in CashuRepoImpl - Created cashu_restore.dart with full restore logic - Added restore method to Cashu class - Created comprehensive tests for restore functionality - Tests verify deterministic secret generation Co-authored-by: 1-leo <58687994+1-leo@users.noreply.github.com>
Co-authored-by: 1-leo <58687994+1-leo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement nut13 and nut09 restore methods in Cashu
Implement NUT-09 wallet restore with NUT-13 deterministic secrets
Feb 4, 2026
- Created comprehensive test that funds wallet1 and restores to wallet2 - Both wallets use the same seed phrase but separate caches - Test verifies that wallet2 can restore all funds from wallet1 - Test is skipped by default but can be enabled for manual testing with real mint - Includes detailed logging and step-by-step verification - Validates that both wallets have identical balances after restore Co-authored-by: 1-leo <58687994+1-leo@users.noreply.github.com>
Co-authored-by: 1-leo <58687994+1-leo@users.noreply.github.com>
Copilot
AI
changed the title
Implement NUT-09 wallet restore with NUT-13 deterministic secrets
Implement proper integration test for Cashu wallet restore
Feb 4, 2026
The bug was in the matching logic between signatures and blinded messages. The code was trying to match by keyset ID, but all blinded messages in a batch share the same keyset ID, so firstWhere always returned the first item. Solution: - Updated restore endpoint to parse BOTH outputs and signatures from response - Match outputs[i] with signatures[i] by index - Use the B_ value from outputs to find the corresponding blinded message item - Fallback to trying each combination if outputs aren't provided This ensures each restored proof gets its correct unique secret and blinding factor. Co-authored-by: 1-leo <58687994+1-leo@users.noreply.github.com>
As requested, the restore method now returns a Stream instead of a Future. This allows clients to track progress as proofs are discovered and restored. Changes: - Changed Cashu.restore() to return Stream<CashuRestoreResult> - Changed CashuRestore.restoreAllKeysets() to return Stream<CashuRestoreResult> - Yields progress updates after each keyset is processed - Saves proofs incrementally and updates balances as they're discovered - Updated test to consume stream and show progress - Added test to verify all proofs have unique secrets (validates the bug fix) Co-authored-by: 1-leo <58687994+1-leo@users.noreply.github.com>
Copilot
AI
changed the title
Implement proper integration test for Cashu wallet restore
Fix restore bug: all proofs had same secret; convert to streaming API
Feb 4, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## cashu-wallet #413 +/- ##
================================================
+ Coverage 72.25% 72.31% +0.05%
================================================
Files 177 179 +2
Lines 7612 7769 +157
================================================
+ Hits 5500 5618 +118
- Misses 2112 2151 +39 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During wallet restoration, all proofs were assigned the same secret and blinding factor. The matching logic used keyset IDs to pair signatures with blinded messages, but all messages in a batch share the same keyset ID, causing
firstWhereto always return the first item.Changes
Fixed signature-to-message matching
outputsandsignaturesfrom NUT-09 restore response (was only parsing signatures)outputs[i]↔signatures[i], then lookup blinded message by B_ valueConverted to streaming API
Cashu.restore()now returnsStream<CashuRestoreResult>instead ofFutureUpdated test
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dev.mint.camelus.app/tmp/dart-sdk/bin/dartvm /tmp/dart-sdk/bin/dartvm --resolved_executable_name=/tmp/dart-sdk/bin/dart --executable_name=/tmp/dart-sdk/bin/dart --mark_main_isolate_as_system_isolate .dart_tool/pub/bin/test/test.dart-3.10.9.snapshot test/cashu/cashu_restore_test.dart(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.