Current state Currently, the type common.Address
is just a generic implementation using a byte array, and utilities for conversion to/from hex strings.
Problem This may prove insufficient, as not every byte array is necessarily a valid address for a given cryptocurrency, and some cryptocurrencies might display addresses in base58 or similar, which would lead to confusion if perun didn't support that representation.
Improvement Proposal I propose that we use a more differentiated interface, which allows individual cryptocurrencies to have a better-fitting data model. Additionally, I suggest we provide a default generic implementation, which is similar to the current one, so that lazy developers can use addresses without implementation overhead.
I suggest the common.Address
interface contains:
ToString() string
: Human-readable string (as employed by the cryptocurrency it belongs to, might be hex, base58, …).
FromString(string) (*Address, error)
: Parsing of a human-readable representation.
FromBytes([]byte) (*Address, error)
: Simple raw deserialisation.
ToBytes() []byte
: Simple raw serialisation.
Additionally, it might be of interest to additionally store which domain/blockchain an address belongs to, in order to make debugging and error checking easier.
I suggest the default implementation be named common.GenericAddress
, and consist of a byte array, and represents addresses as hex strings.