Documentation ¶
Overview ¶
Provides utility functions for Diem Intent Identifier and Account Identifier (https://github.com/diem/lip/blob/master/lips/lip-5.md)
Index ¶
Constants ¶
const ( // MainnetPrefix is mainnet account identifier prefix MainnetPrefix NetworkPrefix = "dm" // TestnetPrefix is testnet account identifier prefix TestnetPrefix NetworkPrefix = "tdm" PreMainnetPrefix NetworkPrefix = "pdm" DryRunMainnetPrefix NetworkPrefix = "ddm" // version 1 V1 byte = 1 // account address length AccountAddressLength = diemtypes.AccountAddressLength SubAddressLength = diemtypes.SubAddressLength )
const ( DiemScheme = "diem" CurrencyParamName = "c" AmountParamName = "am" )
Variables ¶
This section is empty.
Functions ¶
func EncodeAccount ¶
func EncodeAccount(prefix NetworkPrefix, accountAddress diemtypes.AccountAddress, subAddress diemtypes.SubAddress) (string, error)
EncodeAccount creates account v1 encode string Set subAddress == nil for no sub-address case.
Types ¶
type Account ¶
type Account struct { Prefix NetworkPrefix Version byte AccountAddress diemtypes.AccountAddress SubAddress diemtypes.SubAddress }
Account captures all parts of account identifier
func DecodeToAccount ¶
func DecodeToAccount(prefix NetworkPrefix, encodedAccountIdentifier string) (*Account, error)
DecodeToAccount decode given encoded account identifier string to `Account`. Given NetworkPrefix is used to validate account identifier network prefix, and returns error if the network prefix mismatched.
func NewAccount ¶
func NewAccount(prefix NetworkPrefix, accountAddress diemtypes.AccountAddress, subAddress diemtypes.SubAddress) *Account
NewAccount create new Account with version set to v1. Set subAddress == nil for no sub-address case.
type Intent ¶
Intent captures all parts of intent identifier
func DecodeToIntent ¶
func DecodeToIntent(networkPrefix NetworkPrefix, intent string) (*Intent, error)
DecodeToIntent decode given intent string to `Intent`. Given `networkPrefix` is used to validate intent account identifier network prefix.