-
Notifications
You must be signed in to change notification settings - Fork 126
feat(wallet): add offline ecash receiving with DLEQ verification #1931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GEET3001
wants to merge
2
commits into
cashubtc:main
Choose a base branch
from
GEET3001:feat/offline-receive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
12 changes: 12 additions & 0 deletions
12
...es/cdk-sql-common/src/wallet/migrations/postgres/20260423000000_allow_pending_receive.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| -- Migration to add PENDING_RECEIVE to the proof state check constraint | ||
| -- Since the constraint is anonymous in initial migration, we drop and recreate it with a name | ||
|
|
||
| -- Drop potential anonymous constraints (Postgres generates names like proof_state_check) | ||
| DO $$ | ||
| BEGIN | ||
| ALTER TABLE proof DROP CONSTRAINT IF EXISTS proof_state_check; | ||
| EXCEPTION | ||
| WHEN undefined_object THEN null; | ||
| END $$; | ||
|
|
||
| ALTER TABLE proof ADD CONSTRAINT proof_state_check CHECK (state IN ('SPENT', 'UNSPENT', 'PENDING', 'RESERVED', 'PENDING_SPENT', 'PENDING_RECEIVE')); |
39 changes: 39 additions & 0 deletions
39
crates/cdk-sql-common/src/wallet/migrations/sqlite/20260423000000_allow_pending_receive.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| -- Create a new table with the updated CHECK constraint | ||
| CREATE TABLE IF NOT EXISTS proof_new ( | ||
| y BLOB PRIMARY KEY, | ||
| mint_url TEXT NOT NULL, | ||
| state TEXT CHECK ( state IN ('SPENT', 'UNSPENT', 'PENDING', 'RESERVED', 'PENDING_SPENT', 'PENDING_RECEIVE' ) ) NOT NULL, | ||
| spending_condition TEXT, | ||
| unit TEXT NOT NULL, | ||
| amount INTEGER NOT NULL, | ||
| keyset_id TEXT NOT NULL, | ||
| secret TEXT NOT NULL, | ||
| c BLOB NOT NULL, | ||
| witness TEXT, | ||
| dleq_e BLOB, | ||
| dleq_s BLOB, | ||
| dleq_r BLOB, | ||
| used_by_operation TEXT, | ||
| created_by_operation TEXT, | ||
| p2pk_e BLOB | ||
| ); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS secret_index ON proof_new(secret); | ||
| CREATE INDEX IF NOT EXISTS state_index ON proof_new(state); | ||
| CREATE INDEX IF NOT EXISTS spending_condition_index ON proof_new(spending_condition); | ||
| CREATE INDEX IF NOT EXISTS unit_index ON proof_new(unit); | ||
| CREATE INDEX IF NOT EXISTS amount_index ON proof_new(amount); | ||
| CREATE INDEX IF NOT EXISTS mint_url_index ON proof_new(mint_url); | ||
| CREATE INDEX IF NOT EXISTS proof_used_by_operation_index ON proof_new(used_by_operation); | ||
| CREATE INDEX IF NOT EXISTS proof_created_by_operation_index ON proof_new(created_by_operation); | ||
|
|
||
| -- Copy data from old proof table to new proof table | ||
| INSERT INTO proof_new (y, mint_url, state, spending_condition, unit, amount, keyset_id, secret, c, witness, dleq_e, dleq_s, dleq_r, used_by_operation, created_by_operation, p2pk_e) | ||
| SELECT y, mint_url, state, spending_condition, unit, amount, keyset_id, secret, c, witness, dleq_e, dleq_s, dleq_r, used_by_operation, created_by_operation, p2pk_e | ||
| FROM proof; | ||
|
|
||
| -- Drop the old proof table | ||
| DROP TABLE proof; | ||
|
|
||
| -- Rename the new proof table to proof | ||
| ALTER TABLE proof_new RENAME TO proof; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you removed those tests?