feat(#676): emergency withdraw for stuck XLM with 24h timelock - #710
Merged
Eniola3321 merged 2 commits intoAug 1, 2026
Merged
Conversation
Soroban contract (contracts/nft-contract/src/): - storage.rs: add WITHDRAW_TIMELOCK_SECS (86400), set/get/clear withdraw_unlock_time, set/get xlm_token_address - lib.rs: add initiate_withdraw() — admin-only, stores now+24h unlock timestamp and emits withdraw_init event - lib.rs: add withdraw_xlm(recipient, amount_stroops) — admin-only, enforces timelock, clears lock before transfer (CEI pattern), transfers XLM via token SAC, emits withdraw_xlm event - lib.rs: add get_withdraw_unlock_time() view function - lib.rs: add set_xlm_token_address() admin setter - lib.rs: new error variants: WithdrawNotInitiated (15), WithdrawTimelockActive (16), InvalidWithdrawAmount (17), XlmTokenNotConfigured (18) - lib.rs: emit_withdraw_initiated / emit_withdraw_xlm events added NestJS backend (src/nft/nft.controller.ts): - POST /nfts/admin/withdraw/initiate — prepare initiate_withdraw XDR - GET /nfts/admin/withdraw/timelock-status — query unlock time + seconds remaining + ready flag - POST /nfts/admin/withdraw/execute — prepare withdraw_xlm XDR Closes ANYTECHS#676
|
@ellaevans2323-pixel Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Closes #676
Contracts may receive unintended XLM transfers that need recovery. This PR adds a two-step admin-only emergency withdrawal mechanism: the admin must first call
initiate_withdraw()to start a 24-hour timelock, then after it expires callwithdraw_xlm()to recover the funds.Changes
Soroban contract (
contracts/nft-contract/src/)storage.rs
WITHDRAW_TIMELOCK_SECS = 86_400(24 hours)set/get/clear_withdraw_unlock_time— persists the unlock timestamp in instance storageset/get_xlm_token_address— configures the XLM SAC address used for transferslib.rs
initiate_withdraw()— admin-only; storesnow + 86400sas unlock time; emitswithdraw_initeventwithdraw_xlm(recipient, amount_stroops)— admin-only; checks timelock, clears it before transfer (checks-effects-interactions pattern), transfers XLM via token SAC, emitswithdraw_xlmeventget_withdraw_unlock_time()— read-only view returning the pending unlock timestampset_xlm_token_address()— admin setter for the XLM SAC addressWithdrawNotInitiated(15),WithdrawTimelockActive(16),InvalidWithdrawAmount(17),XlmTokenNotConfigured(18)NestJS backend (
src/nft/nft.controller.ts)POST /nfts/admin/withdraw/initiate— prepare unsignedinitiate_withdrawXDR (x-admin-secret required)GET /nfts/admin/withdraw/timelock-status— query unlock time, seconds remaining, and ready flagPOST /nfts/admin/withdraw/execute— prepare unsignedwithdraw_xlmXDRAcceptance Criteria
withdraw_initandwithdraw_xlmevents are emittedsecondsRemainingandreadyflag