-
Notifications
You must be signed in to change notification settings - Fork 13
fix(wallets): use selector ceiling for asset-lock Max #937
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
Merged
Merged
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
3493f71
fix(wallets): use selector ceiling for asset-lock Max
lklimek 807bad5
docs: changelog entry for #929 Max fix
lklimek 6bed93f
fix(wallets): use the real height watermark in the asset-lock ceiling…
lklimek c2abaa4
refactor(wallets): replace the asset-lock ceiling binary search with …
lklimek fcd4c0f
Merge branch 'v1.0-dev' into fix/929-max-shield-snapshot-balance
lklimek 40938d1
fix(wallets): close asset-lock ceiling gaps found by CI review
lklimek e96f20f
fix(ui): migrate remaining asset-lock funding flows to the builder ce…
lklimek aa53542
docs: correct #929 changelog entry to match the fixed scope
lklimek e8d2c26
Merge remote-tracking branch 'origin/fix/929-max-shield-snapshot-bala…
lklimek 8d6f1c9
Merge branch 'v1.0-dev' into fix/929-max-shield-snapshot-balance
lklimek 7ec1505
docs(wallet_backend): document accepted risk from upstream rust-dashc…
lklimek d38b544
fix(wallet_backend): shrink asset-lock probe's write-lock scope, docu…
lklimek d02fd53
fix(ui): harden AssetLockBalanceCache against generation regression a…
lklimek 64cd544
fix(ui): reserve fees for Identity sends, bound ReceiveDeposit by its…
lklimek 48e457f
test(send_screen): seed the asset-lock cache in the Core->Platform ki…
lklimek 0d0e762
docs: correct the Max-fix changelog entry and add its user story
lklimek c127b38
fix(ui): reserve the identity fee at dispatch-time validation, not ju…
lklimek 45c5a0b
fix(ui): debounce the asset-lock probe on no-op events, stop dropping…
lklimek 4d7a3e3
fix(ui): bound ReceiveDeposit dispatch by its address, fix the deboun…
lklimek 85e9f46
fix(wallet_backend): bound the asset-lock probe's worst-case wait wit…
lklimek d652f8f
docs: note the asset-lock probe's timeout in the Max-fix changelog entry
lklimek 33622bb
fix(wallet_backend): remove BnB timeout workaround, close stale-valid…
lklimek 1bc0d96
chore(deps): bump dashpay/platform pin to include the BnB feasibility…
lklimek 03ec120
docs: drop implementation-detail sentence from the Max-fix changelog …
lklimek 8f5c140
fix(wallet_backend): correlate asset-lock probes by request id, disti…
lklimek 4e826bc
fix(wallet): close asset-lock quote freshness gaps from round-5's loc…
lklimek 792e50e
Merge remote-tracking branch 'origin/v1.0-dev' into fix/929-max-shiel…
lklimek bb5234a
Merge remote-tracking branch 'origin/v1.0-dev' into fix/929-max-shiel…
lklimek 4a61f3e
fix(wallet): close round-8 blocking gaps in the asset-lock Max probe …
lklimek 9a5105d
fix(wallet): keep asset-lock Max usable on dust wallets and stop the …
lklimek c4a985f
docs(wallet): correct stale reserved-outpoint claim in observation do…
lklimek 8ea190d
Merge remote-tracking branch 'origin/v1.0-dev' into fix/929-max-shiel…
lklimek 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| //! Stateless asset-lock amount calculations shared by UI flows. | ||
|
|
||
| /// Why an asset-lock amount is outside the builder-derived ceiling. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub enum AssetLockAmountError { | ||
| /// Adding the operation-specific reserve exceeded the amount range. | ||
| Overflow, | ||
| /// The requested amount plus its reserve exceeds the builder ceiling. | ||
| ExceedsMaximum { maximum_amount_duffs: u64 }, | ||
| } | ||
|
|
||
| /// Largest user-entered amount after reserving operation-specific fees. | ||
| /// | ||
| /// Both arguments must use the same unit (duffs or Platform credits). | ||
| pub fn asset_lock_user_max_amount(builder_max: u64, reserve: u64) -> u64 { | ||
| builder_max.saturating_sub(reserve) | ||
| } | ||
|
|
||
| /// Validate a user-entered amount against the live builder-derived ceiling. | ||
| pub fn validate_asset_lock_amount( | ||
| amount_duffs: u64, | ||
| reserve_duffs: u64, | ||
| builder_max_duffs: u64, | ||
| ) -> Result<(), AssetLockAmountError> { | ||
| let required_duffs = amount_duffs | ||
| .checked_add(reserve_duffs) | ||
| .ok_or(AssetLockAmountError::Overflow)?; | ||
| if required_duffs > builder_max_duffs { | ||
| return Err(AssetLockAmountError::ExceedsMaximum { | ||
| maximum_amount_duffs: asset_lock_user_max_amount(builder_max_duffs, reserve_duffs), | ||
| }); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::{AssetLockAmountError, asset_lock_user_max_amount, validate_asset_lock_amount}; | ||
|
|
||
| #[test] | ||
| fn builder_ceiling_validation_reserves_operation_fee() { | ||
| assert_eq!(asset_lock_user_max_amount(10_000, 1_000), 9_000); | ||
| assert_eq!(validate_asset_lock_amount(9_000, 1_000, 10_000), Ok(())); | ||
| assert_eq!( | ||
| validate_asset_lock_amount(9_001, 1_000, 10_000), | ||
| Err(AssetLockAmountError::ExceedsMaximum { | ||
| maximum_amount_duffs: 9_000, | ||
| }) | ||
| ); | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.