Skip to content

Address constructor input validation #48

Open
@pszeder

Description

When creating a new Address object, the public Address(string address) constructor only checks if the address is not null or whitespace. It seems that parsing and validation is implemented in Bech32.Decode(...) which is called within a try-catch block.

As a result, we can have Address objects that are invalid and do not represent any Cardano address. Furthermore, no exceptions are thrown when creating a transaction using such an invalid Address.

The generated CBOR will have null for the address field when used as an output. That is actually not a valid CBOR as per the specification and will likely result in an invalid CBOR/input exception when used with other software - Nami wallet in our case.

I would suggest that an Address should only be constructed if it is valid. That would be 'fail fast' and save people time and headaches.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions