Allow cancellation of approved withdrawal requests#446
Merged
Conversation
bmwill
reviewed
Apr 13, 2026
| #[expected_failure(abort_code = hashi::withdraw::ECannotCancelAfterApproval)] | ||
| /// Cancelling an approved (but not yet processing) request should succeed | ||
| /// and return the full BTC balance to the requester. | ||
| fun test_approve_then_cancel() { |
Contributor
There was a problem hiding this comment.
can we add a test for trying to cancel a request that was entered into the processed state?
Withdrawal requests can now be cancelled while in the Approved state, not just Requested. The BTC balance is still intact until the committee commits the request to a WithdrawalTransaction (Processing), so cancellation is safe in both states.
6344be2 to
9514d84
Compare
Contributor
Author
|
@bmwill ready for another round |
bmwill
approved these changes
Apr 13, 2026
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.
Summary
ECannotCancelAfterApprovalguard fromcancel_withdrawal()RequestedorApprovedstateWithdrawalTransaction(status moves toProcessing, BTC is burned, request moves toprocessedbag), cancellation is no longer possible —borrow_request()will abort since the request is no longer in therequestsbagWhy
Previously, approval was treated as the point of no return. But between
ApprovedandProcessingthere's a window where the request is still in the activerequestsbag with its full BTC balance intact. The actual irreversible step iscommit_requests(), which drains the BTC and moves the request to theprocessedbag. Allowing cancellation in theApprovedstate gives users more flexibility without any safety risk.Test plan
test_approve_then_cancel— now verifies successful cancellation returns full BTCsui move test -p packages/hashi— 71/71 passprettier-move -c— formatting clean🤖 Generated with Claude Code