Repository navigation
feat(identity): add keys with spending limits and raise key limits - #1120
Claudius-Maginificent wants to merge 18 commits into
Conversation
On protocol 14 an authentication key below MASTER can carry a spending limit, an expiry, or both. Limits are validated before anything is sent, and only where the network has proven protocol 14 (IdentityKeyLimits capability). A key's remaining budget is read from Platform. A limits raise is sent exactly as the user reviewed it: refused, not recomputed, when the key's limits or the reviewed signer moved meanwhile. After a raise the key as Platform stores it and the balance after the fee are saved; a raise the network accepted is reported as made even if saving it locally fails. A protocol 13 guard checks that a limited key never goes out as an unlimited version 0 key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map Platform's refusals of limited keys and limits updates (expiry in the past, limit not raised, limit not set, signer with limits, limits not allowed, disabled key) to dedicated TaskError variants with a message that says what to do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Add Key offers a spending limit and an expiry for authentication keys below MASTER, disabled with an explanation on networks without key limits. Key Info shows the total limit, what is left of it, and the expiry, and offers Raise Limits behind a confirmation of the resulting limits and signing key. The keys list marks expired and limited keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🕓 Review not started yet because this PR is a draft.
Commit 1b73759. Normal review starts when eligible; priority review starts as soon as a slot is available. |
…efusals from the signing key branch Merges 4452ae0 from fix/protocol14-signing-key-selection, which carries 74695e7 from chore/bump-platform-063589bf. The conflict in src/backend_task/error.rs keeps both sides: the key limit refusals and the moderation, gas sponsorship and distribution limit refusals each keep their variants, match arms and test cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The merge resolution kept the shared closing brace for the other guard only; this restores it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Upstream's with_limits makes a version 1 key even when no limit is set, and the identity update sends it as is, so a key added from a wallet without limits went out in an encoding protocol 13 networks do not decode. One helper now builds the key for both add paths and keeps a key without limits at version 0, and the backend applies it to every key it adds. The backend also refuses an expiry beyond the longest validity the form allows, so every caller gets the same bound. Also restores the Add Key doc comments the earlier merges dropped, checks validity days in one place, and builds test identities from the shared helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The key limits signer notice names both conditions a critical key must meet, in one sentence shared by Key Info and the refusal. An update that raises nothing gets its own message telling the user what to enter. Key Info reads the live key through the shared lookup, and the spending limit warning and IDN-024 again point at the remaining budget and the key list markers this branch adds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…y limits branch The protocol 13 transition tests go with the file the bump deleted; the two key-limit cases there only checked the protocol 13 encoding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The Platform bump dropped DET's own protocol version copy, so the tests have the SDK prove the version instead of setting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The squash commit's tree equals #1114's final head, which this branch already contains, so the tree is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…to the key limits branch Conflicts: - src/backend_task/dashpay/auto_accept_proof.rs: deleted by #1117 (contact QR codes now go through platform-wallet); this branch only carried #1117's earlier edit of it, so it stays deleted. - src/backend_task/error.rs: this branch's key limits refusals and their test imports stay; the section header and test doc name key limits. - src/context/feature_gate.rs: this branch's IdentityKeyLimits and v1.0-dev's NonTransferableTokens capability and gate both stay; the protocol 14 gate tests cover both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
Next steps: the updated #1117 head is merged into this branch locally and verified (fmt, clippy, area tests); it will be pushed right after #1117. Once #1117 merges, this PR gets retargeted to 🤖 Co-authored by Claudius the Magnificent AI Agent |
…y-limits Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…y-key-limits Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
TL;DR: On networks running protocol 14, you can add an authentication key with a spending limit, an expiry, or both. Key Info shows how much of the limit is left and when the key expires. You can also raise a key's limits after confirming the exact change.
Stacked atop #1117.
User story
Scenario
On testnet, Priya opens Add Key for her identity and adds a HIGH authentication key with a 0.5 DASH spending limit that expires after 30 days.
Key Info for that key shows the total limit, how much is left (read from Platform), and the expiry date. The keys list marks the key as Limited, and later as Expired.
When the key runs low, Priya clicks Raise Limits, adds 0.25 DASH and 30 days, and confirms a summary of:
The app sends exactly that. If the key's limits, or the key that would sign the change, changed in the meantime, nothing is sent and the screen asks her to review again.
On mainnet (protocol 13) the limit fields are shown disabled, with an explanation.
Detailed discussion
Adding a limited key
IdentityKeyLimitscapability. It opens only once the network has proven it runs protocol 14.model/identity_key_limits.rsholds the stateless validation. It refuses, before anything is sent:with_limitsmakes a version 1 key even for no limits, which a protocol 13 network cannot decode.Reading the remaining budget
IdentityTask::FetchKeyRemainingBudgets).Raising limits
KeyLimitsRaise, and the backend sends exactly that raise (IdentityTask::RaiseKeyLimits).KeyLimitsRaisedButNotSaved), so the user does not retry.KeyLimitsRaisedButBalanceNotRefreshed).Refusals
Platform's refusals for limited keys and for limit updates get dedicated messages:
Protocol 13 safety
Guard tests check two things at protocol 13:
Scope
Contract-bound authentication keys (#1123) are not part of this PR.
Testing
tests/kittest/keys_screen.rs).cargo clippy --all-features --all-targets -- -D warningsandcargo fmt --all -- --checkpass.🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q