Skip to content

fix: reject zero-address recipient on withdraw_to#591

Open
zeemscript wants to merge 1 commit into
CalloraOrg:mainfrom
zeemscript:bug/withdraw-zero-recipient
Open

fix: reject zero-address recipient on withdraw_to#591
zeemscript wants to merge 1 commit into
CalloraOrg:mainfrom
zeemscript:bug/withdraw-zero-recipient

Conversation

@zeemscript

Copy link
Copy Markdown

Summary

Closes #572

This PR adds validation to vault.withdraw_to to reject zero-address recipients, preventing funds from being sent to an invalid/burn address.

Changes

  • Added ZeroAddressRecipient error variant (code 37) to VaultError
  • Added is_zero_address helper function that checks if an address is all zero bytes
  • Added validation in withdraw_to that rejects zero-address recipients before amount validation
  • Added NatSpec-style rustdoc documentation to withdraw_to
  • Added focused tests in test_withdraw_to_zero_address.rs:
    • withdraw_to_zero_address_fails - verifies rejection
    • withdraw_to_valid_address_succeeds - verifies normal operation
    • withdraw_to_zero_address_checked_before_amount - verifies check ordering
    • withdraw_to_zero_address_fails_even_when_paused - verifies behavior during pause
    • withdraw_to_valid_after_zero_address_rejection - verifies state unchanged after rejection

Test plan

  • Run cargo test -p callora-vault test_withdraw_to_zero_address
  • Run full test suite cargo test -p callora-vault
  • Run cargo clippy -p callora-vault
  • Verify error code 37 is returned for zero-address recipients

Add validation to withdraw_to function that rejects zero-address
(all zero bytes) recipients with VaultError::ZeroAddressRecipient.

Changes:
- Add ZeroAddressRecipient error variant (code 37)
- Add is_zero_address helper function
- Add validation check in withdraw_to before amount validation
- Add rustdoc documentation for withdraw_to
- Add focused tests in test_withdraw_to_zero_address.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: vault.withdraw_to does not validate recipient is non-zero

1 participant