Skip to content

feat(accounts): support balance drain on forced account deletion#534

Open
dolcalmi wants to merge 5 commits intomainfrom
refactor/account-validator-skip-checks
Open

feat(accounts): support balance drain on forced account deletion#534
dolcalmi wants to merge 5 commits intomainfrom
refactor/account-validator-skip-checks

Conversation

@dolcalmi
Copy link
Copy Markdown

Support safe closure of accounts with positive balances by sweeping funds to a destination account before deletion. Guards against self-transfer, emits audit span attributes on privileged bypass, and consolidates validation bypass under a single skipChecks flag.

…r and payment flows

- Add skipChecks option to AccountValidator to bypass status validation
- Rename cancelIfPositiveBalance to skipChecks in markAccountForDeletion
- Propagate skipChecks through intraledgerPaymentSendWalletId and withSpendingLimits
- Keep bypassMaxDeletions as a separate param for deletion count checks
- Add unit tests for skipChecks behavior in AccountValidator and spending limits
- Resolve destination account (provided or bankowner fallback) before the
  wallet loop; build currency-to-walletId map to match wallets correctly,
  falling back to defaultWalletId when no currency match exists
- Block deletion with AccountHasPositiveBalanceError when skipChecks=false;
  sweep via intraledgerPaymentSendWalletId (admin args) when skipChecks=true
- Wrap sweep failures in InvalidAccountForDeletionError with full context
- Remove skipChecks from IntraLedgerPaymentSendWalletIdArgs; introduce
  IntraLedgerPaymentSendWalletIdAdminArgs for internal/privileged use;
  ForBtcWallet/ForUsdWallet wrappers now explicitly pass skipChecks:false
- Guard withSpendingLimits early-return so skipChecks=true with an apiKeyId
  still runs the lock/settle path
- Default GraphQL skipChecks to false in account-force-delete mutation
- Add code comments documenting skipChecks as admin-only privileged flag
- Update/rewrite unit tests to match new behaviour
…d retry idempotency docs

- Return InvalidAccountForDeletionError when destinationAccountId equals the
  account being deleted, preventing a no-op intra-account sweep that would
  leave funds in a closed account
- Emit addAttributesToCurrentSpan with privilegedBypass, accountId, and
  updatedByPrivilegedClientId when skipChecks=true for audit visibility
- Add JSDoc documenting retry/idempotency semantics on partial sweep failure
- Rename IntraLedgerPaymentSendWalletIdAdminArgs to
  IntraLedgerPaymentSendWalletIdInternalArgs
- Add unit tests covering self-transfer guard and span attribute emission
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant