Documentation ¶
Overview ¶
Package altcurrency provides an enum-like representation of acceptable cryptocurrencies as well as helper functions for tasks like validating addresses and converting currency units.
Index ¶
- func GetBTCAddressVersion(str string) int
- func Keccak256(data ...[]byte) []byte
- func ToChecksumETHAddress(str string) string
- type AltCurrency
- func (a AltCurrency) FromProbi(v decimal.Decimal) decimal.Decimal
- func (a AltCurrency) IsValid() bool
- func (a *AltCurrency) MarshalText() (text []byte, err error)
- func (a AltCurrency) Scale() decimal.Decimal
- func (a AltCurrency) String() string
- func (a AltCurrency) ToProbi(v decimal.Decimal) decimal.Decimal
- func (a *AltCurrency) UnmarshalText(text []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBTCAddressVersion ¶
GetBTCAddressVersion returns the BTC address version of the address str.
func Keccak256 ¶
Keccak256 calculates and returns the Keccak256 hash of the input data. Copied from https://github.com/ethereum/go-ethereum/, licensed under the GNU General Public License v3.0
func ToChecksumETHAddress ¶
ToChecksumETHAddress returns the address str with a checksum encoded in the capitalization per EIP55
Types ¶
type AltCurrency ¶
type AltCurrency int
AltCurrency is an enum-like representing a cryptocurrency FIXME change this to a struct instead of a type alias?
const ( // BAT Basic Attention Token BAT AltCurrency // BTC Bitcoin BTC // ETH Ethereum ETH // LTC Litecoin LTC )
func FromString ¶
func FromString(text string) (AltCurrency, error)
FromString returns the corresponding AltCurrency or error if there is none
func (AltCurrency) FromProbi ¶
func (a AltCurrency) FromProbi(v decimal.Decimal) decimal.Decimal
FromProbi converts v, denominated in subunits to base units of AltCurrency a.
func (AltCurrency) IsValid ¶
func (a AltCurrency) IsValid() bool
IsValid returns true if a is a valid AltCurrency.
func (*AltCurrency) MarshalText ¶
func (a *AltCurrency) MarshalText() (text []byte, err error)
MarshalText marshalls the altcurrency into text.
func (AltCurrency) Scale ¶
func (a AltCurrency) Scale() decimal.Decimal
Scale returns the scalar used to convert between the subunit and the base unit. For example in bitcoin this will be 10^8, as there are 10^8 satoshis (subunit) in one bitcoin (base unit). https://en.wikipedia.org/wiki/Denomination_(currency)#Subunit_and_super_unit
func (AltCurrency) String ¶
func (a AltCurrency) String() string
func (AltCurrency) ToProbi ¶
func (a AltCurrency) ToProbi(v decimal.Decimal) decimal.Decimal
ToProbi converts v, denominated in base units to sub units of AltCurrency a.
func (*AltCurrency) UnmarshalText ¶
func (a *AltCurrency) UnmarshalText(text []byte) (err error)
UnmarshalText unmarshalls the altcurrency from text.