Reject self-transfer (A->A) swap legs#444
Merged
Merged
Conversation
A swap leg's payer and payee are always distinct parties, so a tx whose sender equals the recipient delivers nothing. Without a guard, an operator who lines up the miner's committed address with the user's address could fulfill a swap with a same-wallet self-send and manufacture fake volume. - verify_transaction: reject when sender == expected_recipient (covers both source-confirm and dest-confirm legs at the on-chain choke point). - handle_swap_reserve / handle_swap_confirm: reject when a user address equals the miner's committed deposit/payout address, so a self-flow operator can't even hold a reservation or create the swap. A->B self-flow between two operator-owned wallets is indistinguishable on-chain and still passes; it pays real fees and is bounded on the reward side.
LandynDev
approved these changes
Jun 1, 2026
LandynDev
approved these changes
Jun 1, 2026
This was referenced Jun 3, 2026
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.
What
A swap leg's payer and payee are always distinct parties, so a transaction whose sender equals the recipient delivers nothing to anyone. Without a guard, an operator who lines up the miner's committed address with the user's address could "fulfill" a swap with a same-wallet self-send and manufacture fake volume.
Surfaced while diagnosing swap 2085 (btc→tao): it timed out and was slashed despite a posted
SwapFulfilled. ThedestTxHashdecoded to aBalances.transfer_keep_alivefrom the user to the user's own address (5H3Symui… → 5H3Symui…) for the net amount — not a miner→user delivery. It only failed because the operator used the wrong wallet on the TAO leg; a smarter setup (committingminer_to_address == user_to_address) would have completed.Changes
chain_providers/base.py—verify_transactionrejectssender == expected_recipient. This is the on-chain choke point both source-confirm and dest-confirm route through, so it catches A→A regardless of how addresses were pinned.validator/axon_handlers.py— fail earlier so a self-flow swap is never created:handle_swap_reserve: reject when the userfrom_addressmatches the miner's committed address (source leg, before a reservation is held).handle_swap_confirm: reject whenfrom_address == miner_from_addressorto_address == miner_fulfillment_address(both legs, beforevote_initiate).tests/test_self_transfer_guard.py— A→A rejected (with and without a pinnedexpected_sender); A→B passes.Scope / non-goals
Test
pytest tests/test_self_transfer_guard.py tests/test_axon_handlers.py tests/test_forward.py tests/test_chain_verification.py→ all green.