-
Notifications
You must be signed in to change notification settings - Fork 965
Should Address maintain validity invariants? #648
Description
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