Skip to content

contracts(multisig): validate amount > 0 and to != from in submit_transaction#338

Open
benzy018 wants to merge 1 commit into
VertexChainLabs:mainfrom
benzy018:multisig/validate-submit-transaction-130
Open

contracts(multisig): validate amount > 0 and to != from in submit_transaction#338
benzy018 wants to merge 1 commit into
VertexChainLabs:mainfrom
benzy018:multisig/validate-submit-transaction-130

Conversation

@benzy018

Copy link
Copy Markdown
Contributor

Summary

Fixes the two validation gaps identified in issue #130.

Changes in contracts/multisig/src/lib.rs:

  • Added SelfTransfer = 14 variant to MultiSigError enum
  • submit_transaction now rejects amount <= 0 with InvalidAmount (#6) before storing any state
  • submit_transaction now rejects caller == to with SelfTransfer (#14) before storing any state

Why

  • Storing transactions with amount = 0 or negative amounts silently inflates on-chain pending-tx storage budget with useless entries.
  • Self-transfers are a no-op griefing vector that wastes signer approvals and storage.

Tests Added

Test Expects
test_submit_transaction_rejects_zero_amount Error(Contract, #6)
test_submit_transaction_rejects_negative_amount Error(Contract, #6)
test_submit_transaction_rejects_self_transfer Error(Contract, #14)

All three tests follow the exact same pattern as the existing test_cannot_initialize_twice test using Soroban's #[should_panic(expected = "Error(Contract, #N)")] convention.

Acceptance Criteria

  • Amounts ≤ 0 are rejected
  • Self-transfers (to == caller) are rejected
  • New tests cover both rejection cases

Closes #130

…nsaction

- Add SelfTransfer = 14 variant to MultiSigError enum
- Reject amount <= 0 with InvalidAmount error in submit_transaction
- Reject caller == to with SelfTransfer error in submit_transaction
- Add test_submit_transaction_rejects_zero_amount
- Add test_submit_transaction_rejects_negative_amount
- Add test_submit_transaction_rejects_self_transfer

Closes VertexChainLabs#130
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.

Multisig: validate amount > 0 and validate to != from in submit_transaction

1 participant