Skip to content

bug: an invalid network option silently rejects every address #6

Closed

Description

@Dhananjay-alt
validateAddress('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 'bitcoin', { network: 'foo' as any })
// { valid: false, errorCode: 'NETWORK_MISMATCH', ... }

JavaScript callers, or values coming from config or env, get a misleading NETWORK_MISMATCH instead of a clear error. Chains without a network (EVM and others) still pass, so the behaviour is inconsistent. Suggestion: throw a RangeError for values other than 'mainnet' | 'testnet' | 'auto', the same way an unsupported chain throws.

Activity

  1. added 2 commits that reference this issue on Nov 21, 2026
    4741a8f
    aeb8e3e
  2. Dhananjay-alt commented on Nov 21, 2026

    @Dhananjay-alt
    ContributorAuthor

    Fixed in #10.

    An invalid network option now throws a RangeError instead of reporting NETWORK_MISMATCH (commit 4741a8f). The README and the Unreleased CHANGELOG section are updated.

  3. Samarth208P commented on Nov 21, 2026

    @Samarth208P
    Owner

    Confirmed on main with network: 'foo' from JavaScript. A valid mainnet Bitcoin address returns NETWORK_MISMATCH and a valid Ethereum address succeeds with exactly the same option. That can send a caller looking for a problem with the recipient when the configuration is wrong.

    I’d prioritize a consistent RangeError for unsupported network values. Please cover direct validators, single-address validation, batches (including an empty batch), and detection (including empty input). A valid network: 'mainnet' paired with a real testnet address should still return NETWORK_MISMATCH with the decoded network.

  4. added a commit that references this issue on Nov 21, 2026
    c260f93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions