Skip to content

fix: validate src/dst addresses in alw miner post before chain commit#133

Open
edwin-rivera-dev wants to merge 1 commit into
entrius:testfrom
edwin-rivera-dev:fix/validate-miner-post-addresses
Open

fix: validate src/dst addresses in alw miner post before chain commit#133
edwin-rivera-dev wants to merge 1 commit into
entrius:testfrom
edwin-rivera-dev:fix/validate-miner-post-addresses

Conversation

@edwin-rivera-dev
Copy link
Copy Markdown

Summary

Closes #132

alw miner post accepted src_addr / dst_addr (from interactive prompts or positional args) without any format validation against their declared chains. A typo or cross-chain paste posted successfully and then silently broke every subsequent swap — reserve/confirm/send paths fail individually at the validator or miner, with no local indicator to the posting miner.

This change calls provider.is_valid_address() for both addresses against their respective chains before constructing the commitment string, mirroring the pattern used at allways/cli/swap_commands/swap.py:664-670 for user destination addresses.

Change

  • allways/cli/swap_commands/pair.py: import create_chain_providers; after get_cli_context resolves subtensor, instantiate chain providers and validate src_addr and dst_addr via provider.is_valid_address. Abort with a clear error on either failure.

Behavior notes

  • Both BitcoinProvider.is_valid_address and SubtensorProvider.is_valid_address are local (base58 / bech32 / SS58 format checks; no RPC). Validation is ~milliseconds.
  • Validation runs after chain selection and after get_cli_context so the existing subtensor is reused — no extra connection.
  • Addresses are validated against their user-declared chain, before the canonical-direction normalization. This matches user intent and keeps error messages keyed to what the user typed.
  • No behavior change for already-valid postings.

Test plan

  • ruff check allways/
  • pytest tests/
  • Manual: alw miner post with a good BTC + TAO pair — succeeds.
  • Manual: alw miner post btc 5FsomethingSS58Looking tao bc1q... — aborts with Invalid BTC address: 5F....
  • Manual: alw miner post tao 5F... btc bc1qTYPO — aborts with Invalid BTC address: bc1qTYPO.
  • Manual: interactive wizard with a typo — aborts at the validation step before the confirmation prompt, giving the user a chance to retry without a pending commitment cost.

@edwin-rivera-dev
Copy link
Copy Markdown
Author

Hi, @LandynDev
Could you review the PR please?

@edwin-rivera-dev
Copy link
Copy Markdown
Author

🐛 Fixed
Hi @anderdc , How are you? Could you review this PR please?
Thanks.

@edwin-rivera-dev
Copy link
Copy Markdown
Author

Hi @anderdc ,
Hope you are doing well. Could you review this PR please?
Appreciate. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

alw miner post accepts malformed / wrong-chain addresses and silently breaks all subsequent swaps

2 participants