Skip to content

Should Address maintain validity invariants? #648

@Kixunil

Description

@Kixunil

Address currently neither promises to hold any validity properties nor it denies them (and in fact it seems it does currently check whatever is in FromStr impl).

As a result, code using it should repeat (some) validity checks to avoid problems but such code duplication can actually cause problems (WET code). Some people could even rely on Address being valid.

We should either:

  • Guarantee validity, document it test it and make whatever other measures necessary to make it reliable
  • Document that there's no guarantee so that people don't accidentally rely on them

I'm personally in favor of promising guarantees but if there are good arguments against it I want to hear them. If we do guarantee them should we do unsafe guarantee? (That means if unsafe code assumes them and they are broken are we the ones to blame?) I guess not upholding them despite promise is pretty bad already so we may as well allow unsafe to rely on it.

See https://github.com/rust-bitcoin/rust-bitcoin/pull/563/files#r705268082

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.0Issues and PRs required or helping to stabilize the APIbrainstorm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions