diemid

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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
)
View Source
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.

func (*Account) Encode

func (ai *Account) Encode() (string, error)

Encode encodes Account into SegwitAddr string

type Intent

type Intent struct {
	Account Account
	Params  Params
}

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.

func (*Intent) Encode

func (i *Intent) Encode() (string, error)

type NetworkPrefix

type NetworkPrefix string

NetworkPrefix is account identifier prefix type

type Params

type Params struct {
	Currency string
	Amount   *uint64
}

Params for Intent

Directories

Path Synopsis
Package bech32 reference implementation for Bech32 and segwit addresses.
Package bech32 reference implementation for Bech32 and segwit addresses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL