fix(escrow): reject sender == recipient self-escrows in deposit() - #543
Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Open
Conversation
A sender escrowing funds to themselves had no explicit handling - deposit() would happily lock funds where sender and recipient are the same address. This has no legitimate use in a remittance flow (the same party would be both who can be refunded on expiry and who release() would eventually pay out to) and just ties up funds behind the still-undecided release() authorization mechanism for zero benefit, so it's now rejected with a clear panic instead of silently allowed. Added the check right after require_auth() in deposit(), before the amount/expiry validation, so it's the first thing rejected on a bad call. Tests: added test_deposit_rejects_self_escrow (failure path). The success path (sender != recipient) was already covered by every existing deposit test, so no new success-path test was needed per the issue's acceptance criteria - all 13 pre-existing tests still pass unchanged. 14/14 total. cargo clippy --all-targets -- -D warnings is clean. cargo fmt --check shows the same pre-existing diffs already on main (verified against a clean main checkout before making any changes) - none of them touch code this PR modifies. README updated with a short note on the new validation rule. Closes Northgate-Systems#329
|
Someone is attempting to deploy a commit to the codex723's projects Team on Vercel. A member of the Team first needs to authorize it. |
6 tasks
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
deposit()had no explicit handling forsender == recipient(a self-escrow). This adds a guard that rejects it with a clear panic, decided in favor of "prevent" rather than "allow + document" per the issue's either/or framing: a self-escrow has no legitimate use in a remittance flow (the same party would be both who can be refunded on expiry and whorelease()would eventually pay out to), and it just ties up funds behind the still-undecidedrelease()authorization mechanism for zero benefit.What changed
contracts/escrow/src/lib.rs: added thesender == recipientcheck right afterrequire_auth()indeposit(), before the amount/expiry validation.contracts/escrow/src/test.rs: addedtest_deposit_rejects_self_escrow(failure path). The success path (sender != recipient) is already covered by every existingdeposit()test, so per the issue's acceptance criteria there's no new success-path test needed - all 13 pre-existing tests pass unchanged.contracts/escrow/README.md: short note on the new validation rule under the interface table.Testing
cargo test: 14/14 pass (13 pre-existing + 1 new).cargo clippy --all-targets -- -D warnings: clean, no warnings.cargo fmt --check: shows the same pre-existing diffs already on a cleanmaincheckout (verified before making any changes) - none touch code this PR modifies, left alone rather than reformatting unrelated lines.cargo build --target wasm32-unknown-unknown --release: fails identically on this branch and on a cleanmaincheckout (pre-existingtestutils-feature issue, unrelated, already flagged to the maintainer in earlier PRs).Checklist (from the issue)
contracts/escrow/src/lib.rscargo testpasses locallycargo clippy -- -D warningsandcargo fmt --checkpass (fmt: no new diffs introduced)README.mdupdatedCloses #329