fix: enforce max lockout - #134
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens UTXO locking by enforcing a maximum lock duration (365 days) and replacing potentially panicking chrono arithmetic with checked, total helpers—preventing mutex poisoning and process-wide lockout outages from untrusted inputs.
Changes:
- Introduces
MAX_SECONDS_TO_LOCK_UTXOSwith validation + a checkedlock_expiry_at(..)helper and adds tests for bounds and poison recovery. - Validates lock duration at API boundaries (and within the locker) and maps invalid durations to HTTP 400.
- Updates OpenAPI to document/enforce the maximum lock duration.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| openapi.json | Adds maximum constraints and updates descriptions for lock-duration fields in the published OpenAPI spec. |
| minotari/src/transactions/manager.rs | Switches to checked lock-expiry computation to avoid chrono overflow panics. |
| minotari/src/transactions/fund_locker.rs | Adds max-duration enforcement, total expiry calculation, poison-recovery behavior, and tests covering the new guarantees. |
| minotari/src/api/error.rs | Maps InvalidLockDuration into a client-facing 400 Bad Request. |
| minotari/src/api/accounts/params.rs | Centralizes request default constants and clarifies serde-default behavior when null is provided. |
| minotari/src/api/accounts/fund_lock.rs | Validates lock duration early, handles explicit null defaults safely, and documents maximum via schema annotations. |
| minotari/src/api/accounts/burn.rs | Validates lock duration for burn requests and documents maximum via schema annotations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.