traddr

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 8 Imported by: 3

Documentation

Overview

Helper functions for encoding and decoding Travel Addresses, which are used to specify which VASP controls a specific virtual asset address. OpenVASP and TRP have replaced LNURLs in recent versions to more easily facilitate travel rule transfers and the TRISA protocol recommends the use of a travel address over the use of an LNURL.

https://gitlab.com/OpenVASP/travel-rule-protocol/-/blob/master/core/specification.md?ref_type=heads#travel-address

The base58 encoding implementation was ported from the https://github.com/btcsuite/btcd repository per their ISC license.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrChecksum indicates that the checksum of a check-encoded string does not
	// verify against the checksum.
	ErrChecksum = errors.New("checksum error")

	// ErrInvalidFormat indicates that the check-encoded string has an invalid format.
	ErrInvalidFormat = errors.New("invalid format: version and/or checksum bytes missing")

	// ErrUnhandledScheme indicates that the travel address was not prefixed with ta.
	ErrUnhandledScheme = errors.New("unhandled travel address scheme")

	// ErrMissingQuery indicates that the travel address does not have the query string t=i
	ErrMissingQueryString = errors.New("missing query string")

	// ErrURIScheme indicates that there is a protocol scheme, e.g. https:// in the url
	ErrURIScheme = errors.New("travel address should not contain protocol scheme")

	// ErrInvalidTLD indicates that the URL has no top-level domain
	ErrInvalidTLD = errors.New("invalid top level domain")
)

Functions

func Decode

func Decode(traddr string) (_ string, err error)

Decode a travel address string into a raw URI. The decode method is strict, which means that the travel address must contain the t=i query parameter, a valid TLD, and must not have a URI scheme such as https:// which is implied by the address.

func DecodeURL

func DecodeURL(traddr string) (_ string, err error)

DecodeURL returns a fully formed URL including the https:// URI scheme.

func Encode

func Encode(uri string) (_ string, err error)

Encode a URI into a travel address string. The encode method is strict, which means that the URI must contain the t=i query parameter, a valid TLD, and must not have a URI scheme such as https:// which is implied by the travel rule address.

func Make

func Make(uri string) (_ string, err error)

Make converts a a URI into a travel address string. If the URI contains a scheme such as https:// it is stripped because the https protocol is assumed. If the URI does not contain the t=i query parameter, it is added to the travel address.

Types

type URL

type URL struct {
	url.URL
}

URL extends the net/url package with methods for validing the hostname and TLD.

func Parse

func Parse(rawURL string) (_ *URL, err error)

Parse a raw url into a URL data structure for validation.

func (*URL) ValidTLD

func (u *URL) ValidTLD() error

Jump to

Keyboard shortcuts

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